From 30e123ed351317b7527f632b3b7dc4e81e850449 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 3 Apr 2021 16:23:19 +0200 Subject: Fixed #32575 -- Added support for SpatiaLite 5. --- tests/gis_tests/distapp/tests.py | 8 ++------ tests/gis_tests/geoapp/test_functions.py | 6 +++++- tests/gis_tests/geogapp/tests.py | 9 ++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) (limited to 'tests/gis_tests') diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py index bb03fc20c3..244c99a1d7 100644 --- a/tests/gis_tests/distapp/tests.py +++ b/tests/gis_tests/distapp/tests.py @@ -367,16 +367,12 @@ class DistanceFunctionsTests(FuncTestMixin, TestCase): dist2 = SouthTexasCityFt.objects.annotate(distance=Distance('point', lagrange)).order_by('id') dist_qs = [dist1, dist2] - # Original query done on PostGIS, have to adjust AlmostEqual tolerance - # for Oracle. - tol = 2 if connection.ops.oracle else 5 - # Ensuring expected distances are returned for each distance queryset. for qs in dist_qs: for i, c in enumerate(qs): with self.subTest(c=c): - self.assertAlmostEqual(m_distances[i], c.distance.m, tol) - self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, tol) + self.assertAlmostEqual(m_distances[i], c.distance.m, -1) + self.assertAlmostEqual(ft_distances[i], c.distance.survey_ft, -1) @skipUnlessDBFeature("has_Distance_function", "supports_distance_geodetic") def test_distance_geodetic(self): diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 22d40a4400..a1b1f48e02 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -183,7 +183,11 @@ class GISFunctionsTests(FuncTestMixin, TestCase): def test_azimuth(self): # Returns the azimuth in radians. azimuth_expr = functions.Azimuth(Point(0, 0, srid=4326), Point(1, 1, srid=4326)) - self.assertAlmostEqual(City.objects.annotate(azimuth=azimuth_expr).first().azimuth, math.pi / 4) + self.assertAlmostEqual( + City.objects.annotate(azimuth=azimuth_expr).first().azimuth, + math.pi / 4, + places=2, + ) # Returns None if the two points are coincident. azimuth_expr = functions.Azimuth(Point(0, 0, srid=4326), Point(0, 0, srid=4326)) self.assertIsNone(City.objects.annotate(azimuth=azimuth_expr).first().azimuth) diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py index 53852517e8..7f465f5753 100644 --- a/tests/gis_tests/geogapp/tests.py +++ b/tests/gis_tests/geogapp/tests.py @@ -111,9 +111,12 @@ class GeographyFunctionTests(FuncTestMixin, TestCase): if connection.ops.oracle: ref_dists = [0, 4899.68, 8081.30, 9115.15] elif connection.ops.spatialite: - # SpatiaLite returns non-zero distance for polygons and points - # covered by that polygon. - ref_dists = [326.61, 4899.68, 8081.30, 9115.15] + if connection.ops.spatial_version < (5,): + # SpatiaLite < 5 returns non-zero distance for polygons and points + # covered by that polygon. + ref_dists = [326.61, 4899.68, 8081.30, 9115.15] + else: + ref_dists = [0, 4899.68, 8081.30, 9115.15] else: ref_dists = [0, 4891.20, 8071.64, 9123.95] htown = City.objects.get(name='Houston') -- cgit v1.2.1