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