1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
22 ./blender.bin --background -noaudio --factory-startup --python tests/python/bl_alembic_import_test.py -- --testdir /path/to/lib/tests/alembic
34 class SimpleImportTest(unittest.TestCase):
37 cls.testdir = args.testdir
40 self.assertTrue(self.testdir.exists(),
41 'Test dir %s should exist' % self.testdir)
43 # Make sure we always start with a known-empty file.
44 bpy.ops.wm.open_mainfile(filepath=str(self.testdir / "empty.blend"))
46 def test_import_cube_hierarchy(self):
47 res = bpy.ops.wm.alembic_import(
48 filepath=str(self.testdir / "cubes-hierarchy.abc"),
49 as_background_job=False)
50 self.assertEqual({'FINISHED'}, res)
52 # The objects should be linked to scene_collection in Blender 2.8,
53 # and to scene in Blender 2.7x.
54 objects = bpy.context.scene.objects
55 self.assertEqual(13, len(objects))
58 self.assertIsNone(objects['Cube'].parent)
59 self.assertEqual(objects['Cube'], objects['Cube_001'].parent)
60 self.assertEqual(objects['Cube'], objects['Cube_002'].parent)
61 self.assertEqual(objects['Cube'], objects['Cube_003'].parent)
62 self.assertEqual(objects['Cube_003'], objects['Cube_004'].parent)
63 self.assertEqual(objects['Cube_003'], objects['Cube_005'].parent)
64 self.assertEqual(objects['Cube_003'], objects['Cube_006'].parent)
72 argv = [sys.argv[0]] + sys.argv[sys.argv.index('--')+1:]
76 parser = argparse.ArgumentParser()
77 parser.add_argument('--testdir', required=True, type=pathlib.Path)
78 args, remaining = parser.parse_known_args(argv)
80 unittest.main(argv=remaining)
83 if __name__ == "__main__":
85 # So a python error exits Blender itself too