diff options
| author | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-10-14 10:37:25 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2025-10-15 15:04:16 +0200 |
| commit | 90f7a21b47a3ed232d1daa54c29c0ad156d860c9 (patch) | |
| tree | 10b37af5f29edde6a7a8c1de3a8af42f60074b0b /tests | |
| parent | 28c95a35fbf1a64bb342f622a90fbaaf46315819 (diff) | |
Moved object creation to subTest() in GISFunctionsTests.test_geometry_type() test.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 70c462a78e..daf16ce99d 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -904,39 +904,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") |
