diff options
Diffstat (limited to 'tests/python/collada/animation/test_animation_simple.py')
-rw-r--r-- | tests/python/collada/animation/test_animation_simple.py | 53 |
1 files changed, 34 insertions, 19 deletions
diff --git a/tests/python/collada/animation/test_animation_simple.py b/tests/python/collada/animation/test_animation_simple.py index bdfae03aafb..6b18313c3cd 100644 --- a/tests/python/collada/animation/test_animation_simple.py +++ b/tests/python/collada/animation/test_animation_simple.py @@ -31,6 +31,7 @@ import difflib import pathlib from pathlib import Path + def with_tempdir(wrapped): """Creates a temporary directory for the function, cleaning up after it returns normally. @@ -56,8 +57,10 @@ def with_tempdir(wrapped): return decorator + LINE = "+----------------------------------------------------------------" + class AbstractColladaTest(unittest.TestCase): @classmethod @@ -71,33 +74,33 @@ class AbstractColladaTest(unittest.TestCase): ref = open(reference) exp = open(export) - diff=difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) + diff = difflib.unified_diff(ref.readlines(), exp.readlines(), lineterm='', n=0) ref.close() exp.close() - diff_count = 0; + diff_count = 0 for line in diff: error = True for prefix in ('---', '+++', '@@'): # Ignore diff metadata if line.startswith(prefix): - error=False + error = False break else: # Ignore time stamps for ignore in ('<created>', '<modified>', '<authoring_tool>'): if line[1:].strip().startswith(ignore): - error=False + error = False break if error: - diff_count +=1 + diff_count += 1 pline = line.strip() if diff_count == 1: print("\n%s" % LINE) print("|Test has errors:") print(LINE) pre = "reference" if pline[0] == "-" else "generated" - print ("| %s:%s"% (pre, pline[1:])) + print("| %s:%s" % (pre, pline[1:])) if diff_count > 0: print(LINE) @@ -107,14 +110,16 @@ class AbstractColladaTest(unittest.TestCase): return diff_count == 0 + class MeshExportTest4(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_sample_matrix(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_sample_10_matrix" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -142,20 +147,23 @@ class MeshExportTest4(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest3(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_sample_locrotscale(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_sample_10_channels" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -183,20 +191,23 @@ class MeshExportTest3(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest2(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_keyframe_matrix(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_keyframes_matrix" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -224,20 +235,23 @@ class MeshExportTest2(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): self.fail() + class MeshExportTest1(AbstractColladaTest): @with_tempdir def test_export_animation_suzannes_keyframe_locrotscale(self, tempdir: pathlib.Path): test = "suzannes_parent_inverse_keyframes_channels" reference_dae = self.testdir / Path("%s.dae" % test) - outfile = tempdir / Path("%s_out.dae" % test) + outfile = tempdir / Path("%s_out.dae" % test) - bpy.ops.wm.collada_export(filepath="%s" % str(outfile), + bpy.ops.wm.collada_export( + filepath="%s" % str(outfile), check_existing=True, filemode=8, display_type='DEFAULT', @@ -265,7 +279,8 @@ class MeshExportTest1(AbstractColladaTest): export_texture_type_selection='mat', open_sim=False, limit_precision=True, - keep_bind_info=False) + keep_bind_info=False, + ) # Now check the resulting Collada file. if not self.checkdae(reference_dae, outfile): @@ -277,4 +292,4 @@ if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('--testdir', required=True) args, remaining = parser.parse_known_args() - unittest.main(argv=sys.argv[0:1]+remaining) + unittest.main(argv=sys.argv[0:1] + remaining) |