Skip to content

Commit 097ae90

Browse files
committed
add a unittest for obj file without material
1 parent b4179a4 commit 097ae90

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

test/simple_no_mtl.obj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Blender v2.76 (sub 0) OBJ File: ''
2+
# www.blender.org
3+
o SimpleB
4+
v 0.040000 0.050000 0.060000
5+
v 0.010000 0.020000 0.030000
6+
v 0.070000 0.080000 0.090000
7+
vt 14.000000 15.000000
8+
vt 12.000000 13.000000
9+
vt 10.000000 11.000000
10+
vn 0.879800 0.471100 0.063200
11+
vn 0.577400 0.577400 0.577400
12+
vn 0.894200 0.267700 -0.359000
13+
s 1
14+
f 1/1/1 2/2/2 3/3/3
15+
o Simple
16+
v 0.040000 0.050000 0.060000
17+
v 0.010000 0.020000 0.030000
18+
v 0.070000 0.080000 0.090000
19+
vt 14.000000 15.000000
20+
vt 12.000000 13.000000
21+
vt 10.000000 11.000000
22+
vn 0.879800 0.471100 0.063200
23+
vn 0.577400 0.577400 0.577400
24+
vn 0.894200 0.267700 -0.359000
25+
s 1
26+
f 4/4/4 5/5/5 6/6/6

test/test_wavefront.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,20 @@ def testMissingNormals(self):
5252
"If there are texture coordinates but no normals, should raise an exception."
5353
self.assertRaises(pywavefront.PywavefrontException,
5454
pywavefront.Wavefront, 'simple_missing_normals.obj')
55+
56+
class TestNoMaterial(TestWavefront):
57+
def setUp(self):
58+
pyglet.resource.path.append('@' + __name__)
59+
pyglet.resource.reindex()
60+
# reset the obj file to new file with no mtl line
61+
self.meshes = pywavefront.Wavefront('simple_no_mtl.obj')
62+
63+
def testMaterials(self):
64+
"""Override this method"""
65+
pass
66+
67+
def testMeshMaterialVertices(self):
68+
"Mesh vertices should have known values."
69+
self.assertEqual(len(self.meshes.meshes['Simple'].materials[0].vertices), 48)
70+
71+

0 commit comments

Comments
 (0)