Moved object creation to subTest() in GISFunctionsTests.test_geometry_type() test.

This commit is contained in:
Mariusz Felisiak 2025-10-14 10:37:25 +02:00
parent 02eed4f378
commit 118df57d8d

View file

@ -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")