mirror of
https://github.com/django/django.git
synced 2025-11-20 11:36:04 +00:00
Moved object creation to subTest() in GISFunctionsTests.test_geometry_type() test.
This commit is contained in:
parent
02eed4f378
commit
118df57d8d
1 changed files with 24 additions and 25 deletions
|
|
@ -916,39 +916,38 @@ class GISFunctionsTests(FuncTestMixin, TestCase):
|
||||||
|
|
||||||
@skipUnlessDBFeature("has_GeometryType_function")
|
@skipUnlessDBFeature("has_GeometryType_function")
|
||||||
def test_geometry_type(self):
|
def test_geometry_type(self):
|
||||||
Feature.objects.bulk_create(
|
test_features = [
|
||||||
[
|
Feature(name="Point", geom=Point(0, 0)),
|
||||||
Feature(name="Point", geom=Point(0, 0)),
|
Feature(name="LineString", geom=LineString((0, 0), (1, 1))),
|
||||||
Feature(name="LineString", geom=LineString((0, 0), (1, 1))),
|
Feature(name="Polygon", geom=Polygon(((0, 0), (1, 0), (1, 1), (0, 0)))),
|
||||||
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="MultiPoint", geom=MultiPoint(Point(0, 0), Point(1, 1))),
|
Feature(
|
||||||
Feature(
|
name="MultiLineString",
|
||||||
name="MultiLineString",
|
geom=MultiLineString(
|
||||||
geom=MultiLineString(
|
LineString((0, 0), (1, 1)), LineString((1, 1), (2, 2))
|
||||||
LineString((0, 0), (1, 1)), LineString((1, 1), (2, 2))
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
Feature(
|
),
|
||||||
name="MultiPolygon",
|
Feature(
|
||||||
geom=MultiPolygon(
|
name="MultiPolygon",
|
||||||
Polygon(((0, 0), (1, 0), (1, 1), (0, 0))),
|
geom=MultiPolygon(
|
||||||
Polygon(((1, 1), (2, 1), (2, 2), (1, 1))),
|
Polygon(((0, 0), (1, 0), (1, 1), (0, 0))),
|
||||||
),
|
Polygon(((1, 1), (2, 1), (2, 2), (1, 1))),
|
||||||
),
|
),
|
||||||
]
|
),
|
||||||
)
|
]
|
||||||
|
expected_results = [
|
||||||
expected_results = {
|
|
||||||
("POINT", Point),
|
("POINT", Point),
|
||||||
("LINESTRING", LineString),
|
("LINESTRING", LineString),
|
||||||
("POLYGON", Polygon),
|
("POLYGON", Polygon),
|
||||||
("MULTIPOINT", MultiPoint),
|
("MULTIPOINT", MultiPoint),
|
||||||
("MULTILINESTRING", MultiLineString),
|
("MULTILINESTRING", MultiLineString),
|
||||||
("MULTIPOLYGON", MultiPolygon),
|
("MULTIPOLYGON", MultiPolygon),
|
||||||
}
|
]
|
||||||
|
for test_feature, (geom_type, geom_class) in zip(
|
||||||
for geom_type, geom_class in expected_results:
|
test_features, expected_results, strict=True
|
||||||
with self.subTest(geom_type=geom_type):
|
):
|
||||||
|
with self.subTest(geom_type=geom_type, geom=test_feature.geom.wkt):
|
||||||
|
test_feature.save()
|
||||||
obj = (
|
obj = (
|
||||||
Feature.objects.annotate(
|
Feature.objects.annotate(
|
||||||
geometry_type=functions.GeometryType("geom")
|
geometry_type=functions.GeometryType("geom")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue