@@ -8,35 +8,37 @@ class TestWavefront(unittest.TestCase):
8
8
def setUp (self ):
9
9
pyglet .resource .path .append ('@' + __name__ )
10
10
pyglet .resource .reindex ()
11
+ self .mesh_names = ['Simple' , 'SimpleB' ]
12
+ self .material_names = ['Material.simple' , 'Material2.simple' ]
11
13
self .meshes = pywavefront .Wavefront ('simple.obj' )
12
14
13
15
def testMaterials (self ):
14
16
"Ensure parsed wavefront materials match known values."
15
- self .assertEqual (len (self .meshes .materials ), 2 )
16
- self .assertEqual (self .meshes .materials ['Material.simple' ].__class__ ,
17
- pywavefront .material .Material )
17
+ self .assertEqual (len (self .meshes .materials ), len ( self . material_names ) )
18
+ self .assertEqual (self .meshes .materials [self . material_names [ 0 ] ].__class__ ,
19
+ pywavefront .material .Material )
18
20
19
21
def testMeshes (self ):
20
22
"Ensure parsed wavefront meshes match known values."
21
- self .assertEqual (len (self .meshes .meshes ), 2 )
22
- self .assertEqual (self .meshes .meshes ['Simple' ].__class__ ,
23
+ self .assertEqual (len (self .meshes .meshes ), len ( self . mesh_names ) )
24
+ self .assertEqual (self .meshes .meshes [self . mesh_names [ 0 ] ].__class__ ,
23
25
pywavefront .mesh .Mesh )
24
26
25
27
def testMeshList (self ):
26
28
"Ensure parsed wavefront mesh list matches known values."
27
- self .assertEqual (len (self .meshes .mesh_list ), 2 )
29
+ self .assertEqual (len (self .meshes .mesh_list ), len ( self . mesh_names ) )
28
30
self .assertEqual (self .meshes .mesh_list [0 ].__class__ ,
29
31
pywavefront .mesh .Mesh )
30
32
31
33
def testAddDuplicateMesh (self ):
32
34
"Adding a duplicate mesh should increment the mesh list, but not the meshes hash."
33
- self .meshes .add_mesh (self .meshes .meshes ['Simple' ])
34
- self .assertEqual (len (self .meshes .meshes ), 2 )
35
- self .assertEqual (len (self .meshes .mesh_list ), 3 )
35
+ self .meshes .add_mesh (self .meshes .meshes [self . mesh_names [ 0 ] ])
36
+ self .assertEqual (len (self .meshes .meshes ), len ( self . mesh_names ) )
37
+ self .assertEqual (len (self .meshes .mesh_list ), len ( self . mesh_names ) + 1 )
36
38
37
39
def testMeshMaterialVertices (self ):
38
40
"Mesh vertices should have known values."
39
- self .assertEqual (len (self .meshes .meshes ['Simple' ].materials [0 ].vertices ), 24 )
41
+ self .assertEqual (len (self .meshes .meshes [self . mesh_names [ 0 ] ].materials [0 ].vertices ), 24 )
40
42
41
43
class TestBrokenWavefront (unittest .TestCase ):
42
44
def setUp (self ):
@@ -58,12 +60,19 @@ def setUp(self):
58
60
pyglet .resource .path .append ('@' + __name__ )
59
61
pyglet .resource .reindex ()
60
62
# reset the obj file to new file with no mtl line
63
+ self .mesh_names = ['Simple' , 'SimpleB' ]
64
+ self .material_names = [None ]
61
65
self .meshes = pywavefront .Wavefront ('simple_no_mtl.obj' )
62
66
63
- def testMaterials (self ):
64
- """Override this test"""
65
- pass
66
-
67
67
def testMeshMaterialVertices (self ):
68
68
"Mesh vertices should have known values."
69
- self .assertEqual (len (self .meshes .meshes ['Simple' ].materials [0 ].vertices ), 48 )
69
+ self .assertEqual (len (self .meshes .meshes [self .mesh_names [0 ]].materials [0 ].vertices ), 48 )
70
+
71
+ class TestNoObjectNoMaterial (TestNoMaterial ):
72
+ def setUp (self ):
73
+ pyglet .resource .path .append ('@' + __name__ )
74
+ pyglet .resource .reindex ()
75
+ # reset the obj file to new file with no mtl line
76
+ self .mesh_names = [None ]
77
+ self .material_names = [None ]
78
+ self .meshes = pywavefront .Wavefront ('simple_no_object_no_mtl.obj' )
0 commit comments