From 73587dce4983a886d0510e579f24202f6f8aca38 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Thu, 4 Apr 2024 22:18:20 +0100 Subject: [PATCH] Try workaround --- djgeojson/tests.py | 4 ++-- quicktest.py | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/djgeojson/tests.py b/djgeojson/tests.py index e9274f5..0405518 100644 --- a/djgeojson/tests.py +++ b/djgeojson/tests.py @@ -679,9 +679,9 @@ def test_within_viewport(self): response = self.view.render_to_response(context={}) geojson = json.loads(smart_str(response.content)) self.assertEqual(len(geojson['features']), 2) - self.assertAlmostEqual(geojson['features'][0]['geometry']['coordinates'][0], 6.843322039261242) + self.assertAlmostEqual(geojson['features'][0]['geometry']['coordinates'][0], 6.843321961076886) self.assertAlmostEqual(geojson['features'][0]['geometry']['coordinates'][1], 52.76181518632031) - self.assertAlmostEqual(geojson['features'][1]['geometry']['coordinates'][0], 6.846053318324978) + self.assertAlmostEqual(geojson['features'][1]['geometry']['coordinates'][0], 6.846053240233331 ) self.assertAlmostEqual(geojson['features'][1]['geometry']['coordinates'][1], 52.77442791046052) diff --git a/quicktest.py b/quicktest.py index f22dbed..8749d7f 100644 --- a/quicktest.py +++ b/quicktest.py @@ -69,6 +69,20 @@ def run_tests(self): django.setup() + # Workaround + if django.VERSION >= (4, 0): + + from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper + + def prepare_database(self): + super(DatabaseWrapper, self).prepare_database() + with self.cursor() as cursor: + cursor.execute("PRAGMA table_info(geometry_columns);") + if cursor.fetchall() == []: + cursor.execute("SELECT InitSpatialMetaData(1)") + + DatabaseWrapper.prepare_database = prepare_database + failures = DiscoverRunner().run_tests(self.apps, verbosity=1) if failures: # pragma: no cover sys.exit(failures)