summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-03 05:46:40 +0100
committerGitHub <noreply@github.com>2023-01-03 05:46:40 +0100
commit6774e9359cbdbf7b8c448597c103288ac381519a (patch)
tree5a0e14f0639349980043d60738bd07031bce20cc /tests/gis_tests
parentafa2e28205fe708334ad463b6d3b0e9960b945a6 (diff)
downloaddjango-6774e9359cbdbf7b8c448597c103288ac381519a.tar.gz
Fixed #23842 -- Fixed flaky GeoQuerySetTest.test_make_line() test.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/geoapp/tests.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 2691597225..a4dc5eec75 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -645,18 +645,16 @@ class GeoQuerySetTest(TestCase):
self.assertIsNone(State.objects.aggregate(MakeLine("poly"))["poly__makeline"])
# Reference query:
# SELECT AsText(ST_MakeLine(geoapp_city.point)) FROM geoapp_city;
- ref_line = GEOSGeometry(
- "LINESTRING(-95.363151 29.763374,-96.801611 32.782057,"
- "-97.521157 34.464642,174.783117 -41.315268,-104.609252 38.255001,"
- "-95.23506 38.971823,-87.650175 41.850385,-123.305196 48.462611)",
- srid=4326,
- )
- # We check for equality with a tolerance of 10e-5 which is a lower bound
- # of the precisions of ref_line coordinates
line = City.objects.aggregate(MakeLine("point"))["point__makeline"]
- self.assertTrue(
- ref_line.equals_exact(line, tolerance=10e-5), "%s != %s" % (ref_line, line)
- )
+ ref_points = City.objects.values_list("point", flat=True)
+ self.assertIsInstance(line, LineString)
+ self.assertEqual(len(line), ref_points.count())
+ # Compare pairs of manually sorted points, as the default ordering is
+ # flaky.
+ for (point, ref_city) in zip(sorted(line), sorted(ref_points)):
+ point_x, point_y = point
+ self.assertAlmostEqual(point_x, ref_city.x, 5),
+ self.assertAlmostEqual(point_y, ref_city.y, 5),
@skipUnlessDBFeature("supports_union_aggr")
def test_unionagg(self):