From 738c3f8d38a30f7437d8389b7790103c97f1b73a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 18 May 2023 12:10:05 +0200 Subject: [PATCH] python: improve test coverage for new SceneConverter APIs. --- src/python/magnum/test/test_trade.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/python/magnum/test/test_trade.py b/src/python/magnum/test/test_trade.py index 70a2fb7..64af52e 100644 --- a/src/python/magnum/test/test_trade.py +++ b/src/python/magnum/test/test_trade.py @@ -1851,12 +1851,37 @@ class SceneConverter(unittest.TestCase): with tempfile.TemporaryDirectory() as tmp: filename = os.path.join(tmp, "scene.gltf") converter.begin_file(filename) + self.assertEqual(converter.scene_count, 0) + converter.add(scene, "A default scene that's empty") + self.assertEqual(converter.scene_count, 1) + converter.end_file() with open(filename, 'r') as f: self.assertIn("A default scene that's empty", f.read()) + def test_batch_add_scene_failed(self): + # Static builds with non-static plugins cause assertions with non-owned + # array deleters used by PrimitiveImporter, skip in that case + if magnum.BUILD_STATIC: + self.skipTest("dynamic PrimitiveImporter doesn't work with a static build") + + importer = trade.ImporterManager().load_and_instantiate('PrimitiveImporter') + importer.open_data(containers.ArrayView()) + + scene = importer.scene(0) + self.assertFalse(scene.is_3d) + + converter = trade.SceneConverterManager().load_and_instantiate('GltfSceneConverter') + + with tempfile.TemporaryDirectory() as tmp: + filename = os.path.join(tmp, "scene.gltf") + converter.begin_file(filename) + + with self.assertRaisesRegex(RuntimeError, "adding the scene failed"): + converter.add(scene) + def test_batch_set_default_scene(self): importer = trade.ImporterManager().load_and_instantiate('GltfImporter') importer.open_file(os.path.join(os.path.dirname(__file__), 'scene.gltf'))