diff options
author | Claude Paroz <claude@2xlibre.net> | 2021-04-03 16:23:19 +0200 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-04-08 09:36:29 +0200 |
commit | 30e123ed351317b7527f632b3b7dc4e81e850449 (patch) | |
tree | 4294ff86fa9235ea8c09208fdbecd0f7a1319993 /tests/gis_tests | |
parent | b9d156761f459c889d0c51e6d421d29d8a2f8ae6 (diff) | |
download | django-30e123ed351317b7527f632b3b7dc4e81e850449.tar.gz |
Fixed #32575 -- Added support for SpatiaLite 5.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r-- | tests/gis_tests/distapp/tests.py | 8 | ||||
-rw-r--r-- | tests/gis_tests/geoapp/test_functions.py | 6 | ||||
-rw-r--r-- | tests/gis_tests/geogapp/tests.py | 9 |
3 files changed, 13 insertions, 10 deletions
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') |