From 118df57d8d983d56288255acb7268a2131d97db2 Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 14 Oct 2025 10:37:25 +0200 Subject: [PATCH] Moved object creation to subTest() in GISFunctionsTests.test_geometry_type() test. --- tests/gis_tests/geoapp/test_functions.py | 49 ++++++++++++------------ 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index b1ab4340aa..6a0f3e1f34 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -916,39 +916,38 @@ class GISFunctionsTests(FuncTestMixin, TestCase): @skipUnlessDBFeature("has_GeometryType_function") def test_geometry_type(self): - Feature.objects.bulk_create( - [ - Feature(name="Point", geom=Point(0, 0)), - Feature(name="LineString", geom=LineString((0, 0), (1, 1))), - Feature(name="Polygon", geom=Polygon(((0, 0), (1, 0), (1, 1), (0, 0)))), - Feature(name="MultiPoint", geom=MultiPoint(Point(0, 0), Point(1, 1))), - Feature( - name="MultiLineString", - geom=MultiLineString( - LineString((0, 0), (1, 1)), LineString((1, 1), (2, 2)) - ), + test_features = [ + Feature(name="Point", geom=Point(0, 0)), + Feature(name="LineString", geom=LineString((0, 0), (1, 1))), + Feature(name="Polygon", geom=Polygon(((0, 0), (1, 0), (1, 1), (0, 0)))), + Feature(name="MultiPoint", geom=MultiPoint(Point(0, 0), Point(1, 1))), + Feature( + name="MultiLineString", + geom=MultiLineString( + LineString((0, 0), (1, 1)), LineString((1, 1), (2, 2)) ), - Feature( - name="MultiPolygon", - geom=MultiPolygon( - Polygon(((0, 0), (1, 0), (1, 1), (0, 0))), - Polygon(((1, 1), (2, 1), (2, 2), (1, 1))), - ), + ), + Feature( + name="MultiPolygon", + geom=MultiPolygon( + Polygon(((0, 0), (1, 0), (1, 1), (0, 0))), + Polygon(((1, 1), (2, 1), (2, 2), (1, 1))), ), - ] - ) - - expected_results = { + ), + ] + expected_results = [ ("POINT", Point), ("LINESTRING", LineString), ("POLYGON", Polygon), ("MULTIPOINT", MultiPoint), ("MULTILINESTRING", MultiLineString), ("MULTIPOLYGON", MultiPolygon), - } - - for geom_type, geom_class in expected_results: - with self.subTest(geom_type=geom_type): + ] + for test_feature, (geom_type, geom_class) in zip( + test_features, expected_results, strict=True + ): + with self.subTest(geom_type=geom_type, geom=test_feature.geom.wkt): + test_feature.save() obj = ( Feature.objects.annotate( geometry_type=functions.GeometryType("geom")