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):