|
1 | 1 | import unittest |
2 | | - |
3 | | -import pyglet |
| 2 | +import os |
4 | 3 |
|
5 | 4 | import pywavefront |
6 | 5 |
|
| 6 | +def prepend_dir(file): |
| 7 | + return os.path.join(os.path.dirname(__file__), file) |
| 8 | + |
7 | 9 | class TestWavefront(unittest.TestCase): |
8 | 10 | def setUp(self): |
9 | | - pyglet.resource.path.append('@' + __name__) |
10 | | - pyglet.resource.reindex() |
11 | 11 | self.mesh_names = ['Simple', 'SimpleB'] |
12 | 12 | self.material_names = ['Material.simple', 'Material2.simple'] |
13 | | - self.meshes = pywavefront.Wavefront('simple.obj') |
| 13 | + self.meshes = pywavefront.Wavefront(prepend_dir('simple.obj')) |
14 | 14 |
|
15 | 15 | def testMaterials(self): |
16 | 16 | "Ensure parsed wavefront materials match known values." |
@@ -41,38 +41,31 @@ def testMeshMaterialVertices(self): |
41 | 41 | self.assertEqual(len(self.meshes.meshes[self.mesh_names[0]].materials[0].vertices), 24) |
42 | 42 |
|
43 | 43 | class TestBrokenWavefront(unittest.TestCase): |
44 | | - def setUp(self): |
45 | | - pyglet.resource.path.append('@' + __name__) |
46 | | - pyglet.resource.reindex() |
47 | 44 |
|
48 | 45 | def testUnknownUsemtl(self): |
49 | 46 | "Referencing an unknown material with usemtl should raise an exception." |
50 | 47 | self.assertRaises(pywavefront.PywavefrontException, |
51 | | - pywavefront.Wavefront, 'simple_unknown_usemtl.obj') |
| 48 | + pywavefront.Wavefront, prepend_dir('simple_unknown_usemtl.obj')) |
52 | 49 |
|
53 | 50 | def testMissingNormals(self): |
54 | 51 | "If there are texture coordinates but no normals, should raise an exception." |
55 | 52 | self.assertRaises(pywavefront.PywavefrontException, |
56 | | - pywavefront.Wavefront, 'simple_missing_normals.obj') |
| 53 | + pywavefront.Wavefront, prepend_dir('simple_missing_normals.obj')) |
57 | 54 |
|
58 | 55 | class TestNoMaterial(TestWavefront): |
59 | 56 | def setUp(self): |
60 | | - pyglet.resource.path.append('@' + __name__) |
61 | | - pyglet.resource.reindex() |
62 | 57 | # reset the obj file to new file with no mtl line |
63 | 58 | self.mesh_names = ['Simple', 'SimpleB'] |
64 | 59 | self.material_names = [None] |
65 | | - self.meshes = pywavefront.Wavefront('simple_no_mtl.obj') |
| 60 | + self.meshes = pywavefront.Wavefront(prepend_dir('simple_no_mtl.obj')) |
66 | 61 |
|
67 | 62 | def testMeshMaterialVertices(self): |
68 | 63 | "Mesh vertices should have known values." |
69 | 64 | self.assertEqual(len(self.meshes.meshes[self.mesh_names[0]].materials[0].vertices), 48) |
70 | 65 |
|
71 | 66 | class TestNoObjectNoMaterial(TestNoMaterial): |
72 | 67 | def setUp(self): |
73 | | - pyglet.resource.path.append('@' + __name__) |
74 | | - pyglet.resource.reindex() |
75 | 68 | # reset the obj file to new file with no mtl line |
76 | 69 | self.mesh_names = [None] |
77 | 70 | self.material_names = [None] |
78 | | - self.meshes = pywavefront.Wavefront('simple_no_object_no_mtl.obj') |
| 71 | + self.meshes = pywavefront.Wavefront(prepend_dir('simple_no_object_no_mtl.obj')) |
0 commit comments