Skip to content

Commit a8405f5

Browse files
committed
Test create_material feature
1 parent 106fb26 commit a8405f5

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

test/simple_missing_material.obj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Comment
2+
mtllib simple_missing.mtl
3+
o Simple
4+
v 0.01 0.02 0.03
5+
v 0.04 0.05 0.06
6+
v 0.07 0.08 0.09
7+
v 0.11 0.12 0.13
8+
vt 10 11
9+
vt 12 13
10+
vt 14 15
11+
vt 16 17
12+
vn 20 21 22
13+
usemtl Material.simple
14+
f 2/3/1 1/2/1 3/1/1
15+
o SimpleB
16+
v 1.0 0.0 1.0
17+
v -1.0 0.0 1.0
18+
v 1.0 0.0 -1.0
19+
v -1.0 0.0 -1.0
20+
vt 0.0 1.0
21+
vt 0.0 0.0
22+
vt 1.0 0.0
23+
vt 1.0 1.0
24+
vn 0.0 1.0 -0.0
25+
usemtl Material2.simple
26+
f 6/7/2 5/6/2 7/5/2

test/test_parser.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ def setUp(self):
5454
self.mesh2 = meshes.mesh_list[1]
5555

5656

57+
class TestParserMissingMaterials(unittest.TestCase):
58+
"""Test `create_materials` functionality"""
59+
60+
def test_missing_material_error(self):
61+
"""Parser should crash if `create_materials` is not set"""
62+
with self.assertRaises(IOError):
63+
pywavefront.Wavefront(prepend_dir('simple_missing_material.obj'))
64+
65+
def test_missing_material_create(self):
66+
"""Parser should handle missing materials if `create_materials` is set"""
67+
pywavefront.Wavefront(prepend_dir('simple_missing_material.obj'), create_materials=True)
68+
69+
5770
class TestParserVertexVariants(unittest.TestCase):
5871

5972
def testObjNoNormals(self):

0 commit comments

Comments
 (0)