Browse Source

python: consistently use "out of range" instead of "out of bounds".

next
Vladimír Vondruš 3 years ago
parent
commit
561b8ca901
  1. 12
      src/python/corrade/test/test_containers.py
  2. 14
      src/python/magnum/test/test_trade.py
  3. 6
      src/python/magnum/trade.cpp

12
src/python/corrade/test/test_containers.py

@ -354,7 +354,7 @@ class StridedArrayView1D(unittest.TestCase):
data = b'hello'
data_refcount = sys.getrefcount(data)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
a = containers.StridedArrayView1D(data)[7:8]
self.assertEqual(a.size, (0, ))
@ -1158,7 +1158,7 @@ class BitArray(unittest.TestCase):
a = containers.BitArray.value_init(5)
a_refcount = sys.getrefcount(a)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
b = a[7:8]
self.assertEqual(len(b), 0)
self.assertEqual(b.offset, 5)
@ -1200,7 +1200,7 @@ class BitArray(unittest.TestCase):
a = containers.BitArray.value_init(5)
a_refcount = sys.getrefcount(a)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
b = a[7:8:2]
self.assertEqual(len(b), 0)
self.assertEqual(b.offset, 5)
@ -1360,7 +1360,7 @@ class BitArrayView(unittest.TestCase):
data = containers.BitArray.value_init(5)
data_refcount = sys.getrefcount(data)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
b = containers.BitArrayView(data)[7:8]
self.assertEqual(len(b), 0)
self.assertEqual(b.offset, 5)
@ -1411,7 +1411,7 @@ class BitArrayView(unittest.TestCase):
a = containers.BitArray.value_init(5)
a_refcount = sys.getrefcount(a)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
b = containers.BitArrayView(a)[7:8:2]
self.assertEqual(len(b), 0)
self.assertEqual(b.offset, 5)
@ -1663,7 +1663,7 @@ class StridedBitArrayView1D(unittest.TestCase):
data = containers.BitArray.value_init(5)
data_refcount = sys.getrefcount(data)
# Because this is out of bounds, slice.start = slice.stop
# Because this is out of range, slice.start = slice.stop
b = containers.StridedBitArrayView1D(data)[7:8]
self.assertEqual(len(b), 0)
self.assertEqual(b.offset, 5)

14
src/python/magnum/test/test_trade.py

@ -1411,7 +1411,7 @@ class Importer(unittest.TestCase):
importer.mesh_level_count(0)
with self.assertRaises(IndexError):
importer.mesh_name(0)
with self.assertRaisesRegex(IndexError, "ID out of bounds"):
with self.assertRaisesRegex(IndexError, "ID out of range"):
importer.mesh(0)
with self.assertRaises(IndexError):
@ -1433,13 +1433,13 @@ class Importer(unittest.TestCase):
with self.assertRaises(IndexError):
importer.image3d_name(0)
with self.assertRaisesRegex(IndexError, "ID out of bounds"):
with self.assertRaisesRegex(IndexError, "ID out of range"):
importer.image1d(0)
with self.assertRaisesRegex(IndexError, "level out of bounds"):
with self.assertRaisesRegex(IndexError, "level out of range"):
importer.image2d(0, 1)
with self.assertRaisesRegex(IndexError, "ID out of bounds"):
with self.assertRaisesRegex(IndexError, "ID out of range"):
importer.image2d(1)
with self.assertRaisesRegex(IndexError, "ID out of bounds"):
with self.assertRaisesRegex(IndexError, "ID out of range"):
importer.image3d(0)
def test_open_failed(self):
@ -1566,7 +1566,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.assertRaisesRegex(IndexError, "level out of bounds"):
with self.assertRaisesRegex(IndexError, "level out of range"):
importer.mesh('Non-indexed mesh', 1)
def test_mesh_failed(self):
@ -1629,7 +1629,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.assertRaisesRegex(IndexError, "level out of bounds"):
with self.assertRaisesRegex(IndexError, "level out of range"):
importer.image2d(0, 1)
def test_image2d_by_name(self):

6
src/python/magnum/trade.cpp

@ -429,12 +429,12 @@ template<class R, Containers::Optional<R>(Trade::AbstractImporter::*f)(UnsignedI
}
if(id >= (self.*bounds)()) {
PyErr_SetString(PyExc_IndexError, "ID out of bounds");
PyErr_SetString(PyExc_IndexError, "ID out of range");
throw py::error_already_set{};
}
if(level >= (self.*levelBounds)(id)) {
PyErr_SetString(PyExc_IndexError, "level out of bounds");
PyErr_SetString(PyExc_IndexError, "level out of range");
throw py::error_already_set{};
}
@ -462,7 +462,7 @@ template<class R, Containers::Optional<R>(Trade::AbstractImporter::*f)(UnsignedI
}
if(level >= (self.*levelBounds)(id)) {
PyErr_SetString(PyExc_IndexError, "level out of bounds");
PyErr_SetString(PyExc_IndexError, "level out of range");
throw py::error_already_set{};
}

Loading…
Cancel
Save