diff --git a/src/python/magnum/test/test_trade.py b/src/python/magnum/test/test_trade.py index 42173a9..891390e 100644 --- a/src/python/magnum/test/test_trade.py +++ b/src/python/magnum/test/test_trade.py @@ -657,7 +657,7 @@ class Importer(unittest.TestCase): importer.mesh_level_count(0) with self.assertRaises(IndexError): importer.mesh_name(0) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "ID out of bounds"): importer.mesh(0) with self.assertRaises(IndexError): @@ -674,13 +674,13 @@ class Importer(unittest.TestCase): with self.assertRaises(IndexError): importer.image3d_name(0) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "ID out of bounds"): importer.image1d(0) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "level out of bounds"): importer.image2d(0, 1) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "ID out of bounds"): importer.image2d(1) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "ID out of bounds"): importer.image3d(0) def test_open_failed(self): @@ -750,7 +750,7 @@ class Importer(unittest.TestCase): importer = trade.ImporterManager().load_and_instantiate('GltfImporter') importer.open_file(os.path.join(os.path.dirname(__file__), 'mesh.gltf')) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "level out of bounds"): importer.mesh('Non-indexed mesh', 1) def test_mesh_failed(self): @@ -790,7 +790,7 @@ class Importer(unittest.TestCase): importer = trade.ImporterManager().load_and_instantiate('StbImageImporter') importer.open_file(os.path.join(os.path.dirname(__file__), 'rgb.png')) - with self.assertRaises(IndexError): + with self.assertRaisesRegex(IndexError, "level out of bounds"): importer.image2d(0, 1) def test_image2d_by_name(self): diff --git a/src/python/magnum/trade.cpp b/src/python/magnum/trade.cpp index ff976e8..7f46c76 100644 --- a/src/python/magnum/trade.cpp +++ b/src/python/magnum/trade.cpp @@ -329,12 +329,12 @@ template(Trade::AbstractImporter::*f)(UnsignedI } if(id >= (self.*bounds)()) { - PyErr_SetNone(PyExc_IndexError); + PyErr_SetString(PyExc_IndexError, "ID out of bounds"); throw py::error_already_set{}; } if(level >= (self.*levelBounds)(id)) { - PyErr_SetNone(PyExc_IndexError); + PyErr_SetString(PyExc_IndexError, "level out of bounds"); throw py::error_already_set{}; } @@ -362,7 +362,7 @@ template(Trade::AbstractImporter::*f)(UnsignedI } if(level >= (self.*levelBounds)(id)) { - PyErr_SetNone(PyExc_IndexError); + PyErr_SetString(PyExc_IndexError, "level out of bounds"); throw py::error_already_set{}; }