summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorDavid Smith <smithdc@gmail.com>2024-11-07 20:37:16 +0000
committernessita <124304+nessita@users.noreply.github.com>2025-07-21 22:23:29 -0300
commit49cb481f3dd776882ad7c205f835211b4b3fcab4 (patch)
treea10a5c1a58a7d3f4beb68df5a545f9211aa72c58 /tests/gis_tests
parentef42718a2b5ca941931d49221928d88ce24206c9 (diff)
Added message to TypeError exceptions in GEOS WKTReader and WKBReader.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/geos_tests/test_io.py24
1 files changed, 18 insertions, 6 deletions
diff --git a/tests/gis_tests/geos_tests/test_io.py b/tests/gis_tests/geos_tests/test_io.py
index 35cf0c11ad..14646ce385 100644
--- a/tests/gis_tests/geos_tests/test_io.py
+++ b/tests/gis_tests/geos_tests/test_io.py
@@ -29,15 +29,23 @@ class GEOSIOTest(SimpleTestCase):
self.assertEqual(ref, geom)
# Should only accept string objects.
- with self.assertRaises(TypeError):
- wkt_r.read(1)
- with self.assertRaises(TypeError):
- wkt_r.read(memoryview(b"foo"))
+ bad_input = (1, 5.23, None, False, memoryview(b"foo"))
+ msg = "'wkt' must be bytes or str (got {} instead)."
+ for bad_wkt in bad_input:
+ with (
+ self.subTest(bad_wkt=bad_wkt),
+ self.assertRaisesMessage(TypeError, msg.format(bad_wkt)),
+ ):
+ wkt_r.read(bad_wkt)
def test02_wktwriter(self):
# Creating a WKTWriter instance, testing its ptr property.
wkt_w = WKTWriter()
- with self.assertRaises(TypeError):
+ msg = (
+ "Incompatible pointer type: "
+ "<class 'django.contrib.gis.geos.prototypes.io.LP_WKTReader_st'>."
+ )
+ with self.assertRaisesMessage(TypeError, msg):
wkt_w.ptr = WKTReader.ptr_type()
ref = GEOSGeometry("POINT (5 23)")
@@ -72,8 +80,12 @@ class GEOSIOTest(SimpleTestCase):
self.assertEqual(ref, geom)
bad_input = (1, 5.23, None, False)
+ msg = "'wkb' must be bytes, str or memoryview (got {} instead)."
for bad_wkb in bad_input:
- with self.assertRaises(TypeError):
+ with (
+ self.subTest(bad_wkb=bad_wkb),
+ self.assertRaisesMessage(TypeError, msg.format(bad_wkb)),
+ ):
wkb_r.read(bad_wkb)
def test04_wkbwriter(self):