From 8ccd378870e28229c65f5c47aab2bc136ed20152 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 9 Feb 2023 00:15:33 +0100 Subject: [PATCH] python: test trade.AbstractImporter.mesh() failure. --- src/python/magnum/test/mesh.gltf | 8 ++++++++ src/python/magnum/test/test_trade.py | 11 ++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/python/magnum/test/mesh.gltf b/src/python/magnum/test/mesh.gltf index 285cd3a..d5bbfbc 100644 --- a/src/python/magnum/test/mesh.gltf +++ b/src/python/magnum/test/mesh.gltf @@ -30,6 +30,14 @@ } } ] + }, + { + "name": "A broken mesh", + "primitives": [ + { + "mode": 666 + } + ] } ], "accessors": [ diff --git a/src/python/magnum/test/test_trade.py b/src/python/magnum/test/test_trade.py index 74faf18..9ad9a45 100644 --- a/src/python/magnum/test/test_trade.py +++ b/src/python/magnum/test/test_trade.py @@ -706,7 +706,7 @@ class Importer(unittest.TestCase): self.assertIsNone(importer.mesh_attribute_for_name("_CUSTOM_ATTRIBUTE")) importer.open_file(os.path.join(os.path.dirname(__file__), 'mesh.gltf')) - self.assertEqual(importer.mesh_count, 2) + self.assertEqual(importer.mesh_count, 3) self.assertEqual(importer.mesh_level_count(0), 1) self.assertEqual(importer.mesh_name(0), 'Indexed mesh') self.assertEqual(importer.mesh_for_name('Indexed mesh'), 0) @@ -753,6 +753,15 @@ class Importer(unittest.TestCase): with self.assertRaises(IndexError): importer.mesh('Non-indexed mesh', 1) + def test_mesh_failed(self): + importer = trade.ImporterManager().load_and_instantiate('GltfImporter') + importer.open_file(os.path.join(os.path.dirname(__file__), 'mesh.gltf')) + + with self.assertRaisesRegex(RuntimeError, "import failed"): + importer.mesh(2) + with self.assertRaisesRegex(RuntimeError, "import failed"): + importer.mesh('A broken mesh') + def test_image2d(self): manager = trade.ImporterManager() manager_refcount = sys.getrefcount(manager)