From 2a2481f5a2179ac11947d92a097c9042bb57e17c Mon Sep 17 00:00:00 2001 From: David Smith <39445562+smithdc1@users.noreply.github.com> Date: Tue, 26 Dec 2023 20:23:33 +0000 Subject: [PATCH] Refs #35058 -- Added __repr__() to OGRGeomType. --- django/contrib/gis/gdal/geomtype.py | 3 +++ tests/gis_tests/gdal_tests/test_geom.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 8b77cafa34..6f342b3c96 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -55,6 +55,9 @@ class OGRGeomType: "Return the value of the name property." return self.name + def __repr__(self): + return f"<{self.__class__.__qualname__}: {self.name}>" + def __eq__(self, other): """ Do an equivalence test on the OGR type with the given diff --git a/tests/gis_tests/gdal_tests/test_geom.py b/tests/gis_tests/gdal_tests/test_geom.py index 175ec3c7da..913e465ef1 100644 --- a/tests/gis_tests/gdal_tests/test_geom.py +++ b/tests/gis_tests/gdal_tests/test_geom.py @@ -58,6 +58,9 @@ class OGRGeomTest(SimpleTestCase, TestDataMixin): self.assertEqual(0, gt.num) self.assertEqual("Unknown", gt.name) + def test_geom_type_repr(self): + self.assertEqual(repr(OGRGeomType("point")), "") + def test_geomtype_25d(self): "Testing OGRGeomType object with 25D types." wkb25bit = OGRGeomType.wkb25bit