diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index aa356e30a2..a386896d24 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -12,7 +12,7 @@ from django.db import NotSupportedError, connection from django.db.models import Sum from django.test import TestCase, skipUnlessDBFeature -from ..utils import FuncTestMixin, mysql, oracle, postgis, spatialite +from ..utils import FuncTestMixin, mariadb, mysql, oracle, postgis, spatialite from .models import City, Country, CountryWebMercator, State, Track @@ -85,7 +85,7 @@ class GISFunctionsTests(FuncTestMixin, TestCase): # WHERE "geoapp_city"."name" = 'Chicago'; # Finally, we set every available keyword. # MariaDB doesn't limit the number of decimals in bbox. - if mysql and connection.mysql_is_mariadb: + if mariadb: chicago_json['bbox'] = [-87.650175, 41.850385, -87.650175, 41.850385] self.assertJSONEqual( City.objects.annotate( diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py index 47d16434a5..c97bce5f32 100644 --- a/tests/gis_tests/geoapp/tests.py +++ b/tests/gis_tests/geoapp/tests.py @@ -13,7 +13,8 @@ from django.db import NotSupportedError, connection from django.test import TestCase, skipUnlessDBFeature from ..utils import ( - mysql, no_oracle, oracle, postgis, skipUnlessGISLookup, spatialite, + mariadb, mysql, no_oracle, oracle, postgis, skipUnlessGISLookup, + spatialite, ) from .models import ( City, Country, Feature, MinusOneSRID, NonConcreteModel, PennsylvaniaCity, @@ -227,8 +228,7 @@ class GeoLookupTest(TestCase): def test_disjoint_lookup(self): "Testing the `disjoint` lookup type." - if (connection.vendor == 'mysql' and not connection.mysql_is_mariadb and - connection.mysql_version < (8, 0, 0)): + if mysql and not mariadb and connection.mysql_version < (8, 0, 0): raise unittest.SkipTest('MySQL < 8 gives different results.') ptown = City.objects.get(name='Pueblo') qs1 = City.objects.filter(point__disjoint=ptown.point) diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index 35fedf8eb6..5fac4d9884 100644 --- a/tests/gis_tests/inspectapp/tests.py +++ b/tests/gis_tests/inspectapp/tests.py @@ -10,7 +10,7 @@ from django.test import SimpleTestCase, TestCase, skipUnlessDBFeature from django.test.utils import modify_settings from ..test_data import TEST_DATA -from ..utils import postgis +from ..utils import mariadb, postgis from .models import AllOGRFields @@ -141,7 +141,7 @@ class OGRInspectTest(SimpleTestCase): else: self.assertIn(' f_decimal = models.DecimalField(max_digits=0, decimal_places=0)', model_def) self.assertIn(' f_int = models.IntegerField()', model_def) - if connection.vendor != 'mysql' or not connection.mysql_is_mariadb: + if not mariadb: # Probably a bug between GDAL and MariaDB on time fields. self.assertIn(' f_datetime = models.DateTimeField()', model_def) self.assertIn(' f_time = models.TimeField()', model_def) diff --git a/tests/gis_tests/utils.py b/tests/gis_tests/utils.py index b30da7e40d..23a99eb66c 100644 --- a/tests/gis_tests/utils.py +++ b/tests/gis_tests/utils.py @@ -46,6 +46,7 @@ _default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] oracle = _default_db == 'oracle' postgis = _default_db == 'postgis' mysql = _default_db == 'mysql' +mariadb = mysql and connection.mysql_is_mariadb spatialite = _default_db == 'spatialite' # MySQL spatial indices can't handle NULL geometries.