diff --git a/tests/gis_tests/distapp/models.py b/tests/gis_tests/distapp/models.py index be4cf50f95..45384e4e43 100644 --- a/tests/gis_tests/distapp/models.py +++ b/tests/gis_tests/distapp/models.py @@ -12,7 +12,6 @@ class NamedModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] def __str__(self): return self.name diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py index 3079afb9d7..4609083f3b 100644 --- a/tests/gis_tests/distapp/tests.py +++ b/tests/gis_tests/distapp/tests.py @@ -19,7 +19,6 @@ from .models import ( ) -@skipUnlessDBFeature("gis_enabled") class DistanceTest(TestCase): fixtures = ['initial'] @@ -463,7 +462,6 @@ Perimeter(geom1) | OK | :-( ''' # NOQA -@skipUnlessDBFeature("gis_enabled") class DistanceFunctionsTests(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geo3d/models.py b/tests/gis_tests/geo3d/models.py index f2ea0e02d9..fb6cb43dae 100644 --- a/tests/gis_tests/geo3d/models.py +++ b/tests/gis_tests/geo3d/models.py @@ -10,7 +10,6 @@ class NamedModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] def __str__(self): return self.name @@ -49,7 +48,6 @@ class SimpleModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] class Point2D(SimpleModel): diff --git a/tests/gis_tests/geo3d/tests.py b/tests/gis_tests/geo3d/tests.py index bccf640d4e..36b9eea869 100644 --- a/tests/gis_tests/geo3d/tests.py +++ b/tests/gis_tests/geo3d/tests.py @@ -97,7 +97,7 @@ class Geo3DLoadingHelper(object): Polygon3D.objects.create(name='3D BBox', poly=bbox_3d) -@skipUnlessDBFeature("gis_enabled", "supports_3d_storage") +@skipUnlessDBFeature("supports_3d_storage") class Geo3DTest(Geo3DLoadingHelper, TestCase): """ Only a subset of the PostGIS routines are 3D-enabled, and this TestCase @@ -310,7 +310,7 @@ class Geo3DTest(Geo3DLoadingHelper, TestCase): self.assertEqual(city_dict[city.name][2] + ztrans, city.translate.z) -@skipUnlessDBFeature("gis_enabled", "supports_3d_functions") +@skipUnlessDBFeature("supports_3d_functions") class Geo3DFunctionsTests(Geo3DLoadingHelper, TestCase): def test_kml(self): """ diff --git a/tests/gis_tests/geoadmin/models.py b/tests/gis_tests/geoadmin/models.py index e57dcd7e9a..e4186a9673 100644 --- a/tests/gis_tests/geoadmin/models.py +++ b/tests/gis_tests/geoadmin/models.py @@ -11,7 +11,6 @@ class City(models.Model): class Meta: app_label = 'geoadmin' - required_db_features = ['gis_enabled'] def __str__(self): return self.name diff --git a/tests/gis_tests/geoadmin/tests.py b/tests/gis_tests/geoadmin/tests.py index 88c3934020..a2a604e8bc 100644 --- a/tests/gis_tests/geoadmin/tests.py +++ b/tests/gis_tests/geoadmin/tests.py @@ -2,14 +2,13 @@ from __future__ import unicode_literals from django.contrib.gis import admin from django.contrib.gis.geos import Point -from django.test import TestCase, override_settings, skipUnlessDBFeature +from django.test import TestCase, override_settings from django.test.utils import patch_logger from .admin import UnmodifiableAdmin from .models import City, site -@skipUnlessDBFeature("gis_enabled") @override_settings(ROOT_URLCONF='django.contrib.gis.tests.geoadmin.urls') class GeoAdminTest(TestCase): diff --git a/tests/gis_tests/geoapp/models.py b/tests/gis_tests/geoapp/models.py index 62103d268d..0392027e69 100644 --- a/tests/gis_tests/geoapp/models.py +++ b/tests/gis_tests/geoapp/models.py @@ -12,7 +12,6 @@ class NamedModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] def __str__(self): return self.name @@ -31,7 +30,6 @@ class City(NamedModel): class Meta: app_label = 'geoapp' - required_db_features = ['gis_enabled'] # This is an inherited model from City @@ -41,7 +39,6 @@ class PennsylvaniaCity(City): class Meta: app_label = 'geoapp' - required_db_features = ['gis_enabled'] class State(NamedModel): @@ -49,7 +46,6 @@ class State(NamedModel): class Meta: app_label = 'geoapp' - required_db_features = ['gis_enabled'] class Track(NamedModel): @@ -61,9 +57,6 @@ class MultiFields(NamedModel): point = models.PointField() poly = models.PolygonField() - class Meta: - required_db_features = ['gis_enabled'] - class UniqueTogetherModel(models.Model): city = models.CharField(max_length=30) @@ -71,15 +64,12 @@ class UniqueTogetherModel(models.Model): class Meta: unique_together = ('city', 'point') - required_db_features = ['gis_enabled', 'supports_geometry_field_unique_index'] + required_db_features = ['supports_geometry_field_unique_index'] class Truth(models.Model): val = models.BooleanField(default=False) - class Meta: - required_db_features = ['gis_enabled'] - class Feature(NamedModel): geom = models.GeometryField() @@ -88,9 +78,6 @@ class Feature(NamedModel): class MinusOneSRID(models.Model): geom = models.PointField(srid=-1) # Minus one SRID. - class Meta: - required_db_features = ['gis_enabled'] - class NonConcreteField(models.IntegerField): diff --git a/tests/gis_tests/geoapp/test_expressions.py b/tests/gis_tests/geoapp/test_expressions.py index c18d07f0e8..503b706f0e 100644 --- a/tests/gis_tests/geoapp/test_expressions.py +++ b/tests/gis_tests/geoapp/test_expressions.py @@ -8,7 +8,6 @@ from ..utils import postgis from .models import City -@skipUnlessDBFeature('gis_enabled') class GeoExpressionsTests(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geoapp/test_feeds.py b/tests/gis_tests/geoapp/test_feeds.py index 0974554737..3e1d91e17e 100644 --- a/tests/gis_tests/geoapp/test_feeds.py +++ b/tests/gis_tests/geoapp/test_feeds.py @@ -4,16 +4,13 @@ from xml.dom import minidom from django.conf import settings from django.contrib.sites.models import Site -from django.test import ( - TestCase, modify_settings, override_settings, skipUnlessDBFeature, -) +from django.test import TestCase, modify_settings, override_settings from .models import City @modify_settings(INSTALLED_APPS={'append': 'django.contrib.sites'}) @override_settings(ROOT_URLCONF='gis_tests.geoapp.urls') -@skipUnlessDBFeature("gis_enabled") class GeoFeedTest(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py index 56ba63673b..a3ffc40ecd 100644 --- a/tests/gis_tests/geoapp/test_functions.py +++ b/tests/gis_tests/geoapp/test_functions.py @@ -15,7 +15,6 @@ from ..utils import mysql, oracle, postgis, spatialite from .models import City, Country, CountryWebMercator, State, Track -@skipUnlessDBFeature("gis_enabled") class GISFunctionsTests(TestCase): """ Testing functions from django/contrib/gis/db/models/functions.py. diff --git a/tests/gis_tests/geoapp/test_regress.py b/tests/gis_tests/geoapp/test_regress.py index 7aa99966e3..a9d160c534 100644 --- a/tests/gis_tests/geoapp/test_regress.py +++ b/tests/gis_tests/geoapp/test_regress.py @@ -12,7 +12,6 @@ from ..utils import no_oracle from .models import City, PennsylvaniaCity, State, Truth -@skipUnlessDBFeature("gis_enabled") class GeoRegressionTests(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py index f82edfa53e..d267ccd28b 100644 --- a/tests/gis_tests/geoapp/test_serializers.py +++ b/tests/gis_tests/geoapp/test_serializers.py @@ -4,12 +4,11 @@ import json from django.contrib.gis.geos import LinearRing, Point, Polygon from django.core import serializers -from django.test import TestCase, skipUnlessDBFeature +from django.test import TestCase from .models import City, MultiFields, PennsylvaniaCity -@skipUnlessDBFeature("gis_enabled") class GeoJSONSerializerTests(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geoapp/test_sitemaps.py b/tests/gis_tests/geoapp/test_sitemaps.py index e17a48a624..4e5d1c59aa 100644 --- a/tests/gis_tests/geoapp/test_sitemaps.py +++ b/tests/gis_tests/geoapp/test_sitemaps.py @@ -6,16 +6,13 @@ from xml.dom import minidom from django.conf import settings from django.contrib.sites.models import Site -from django.test import ( - TestCase, modify_settings, override_settings, skipUnlessDBFeature, -) +from django.test import TestCase, modify_settings, override_settings from .models import City, Country @modify_settings(INSTALLED_APPS={'append': ['django.contrib.sites', 'django.contrib.sitemaps']}) @override_settings(ROOT_URLCONF='gis_tests.geoapp.urls') -@skipUnlessDBFeature("gis_enabled") class GeoSitemapTest(TestCase): def setUp(self): diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py index 7c4e8b8dfb..3338a32109 100644 --- a/tests/gis_tests/geoapp/tests.py +++ b/tests/gis_tests/geoapp/tests.py @@ -22,7 +22,6 @@ from .models import ( ) -@skipUnlessDBFeature("gis_enabled") class GeoModelTest(TestCase): fixtures = ['initial'] @@ -223,7 +222,6 @@ class GeoModelTest(TestCase): self.assertEqual(feature.geom.srid, g.srid) -@skipUnlessDBFeature("gis_enabled") class GeoLookupTest(TestCase): fixtures = ['initial'] @@ -450,7 +448,6 @@ class GeoLookupTest(TestCase): self.assertEqual('Lawrence', City.objects.get(point__relate=(ks.poly, intersects_mask)).name) -@skipUnlessDBFeature("gis_enabled") @ignore_warnings(category=RemovedInDjango20Warning) class GeoQuerySetTest(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/geogapp/models.py b/tests/gis_tests/geogapp/models.py index 3d2a12826a..75102d22c9 100644 --- a/tests/gis_tests/geogapp/models.py +++ b/tests/gis_tests/geogapp/models.py @@ -10,7 +10,6 @@ class NamedModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] def __str__(self): return self.name @@ -21,7 +20,6 @@ class City(NamedModel): class Meta: app_label = 'geogapp' - required_db_features = ['gis_enabled'] class Zipcode(NamedModel): @@ -35,7 +33,6 @@ class County(NamedModel): class Meta: app_label = 'geogapp' - required_db_features = ['gis_enabled'] def __str__(self): return ' County, '.join([self.name, self.state]) diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py index 89a47405ce..a23dad3a53 100644 --- a/tests/gis_tests/geogapp/tests.py +++ b/tests/gis_tests/geogapp/tests.py @@ -21,7 +21,6 @@ from ..utils import oracle, postgis, spatialite from .models import City, County, Zipcode -@skipUnlessDBFeature("gis_enabled") class GeographyTest(TestCase): fixtures = ['initial'] @@ -115,7 +114,6 @@ class GeographyTest(TestCase): self.assertEqual(rounded_value, 5439000) -@skipUnlessDBFeature("gis_enabled") class GeographyFunctionTests(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/gis_migrations/migrations/0001_initial.py b/tests/gis_tests/gis_migrations/migrations/0001_initial.py index d92bb3b0e2..918b56554f 100644 --- a/tests/gis_tests/gis_migrations/migrations/0001_initial.py +++ b/tests/gis_tests/gis_migrations/migrations/0001_initial.py @@ -10,7 +10,6 @@ ops = [ ('geom', models.MultiPolygonField(srid=4326)), ], options={ - 'required_db_features': ['gis_enabled'], }, bases=(models.Model,), ), @@ -29,7 +28,6 @@ ops = [ ('geom', models.PointField(srid=4326, geography=True)), ], options={ - 'required_db_features': ['gis_enabled'], }, bases=(models.Model,), ), @@ -51,7 +49,7 @@ ops = [ ) ] -if connection.features.gis_enabled and connection.features.supports_raster: +if connection.features.supports_raster: ops += [ migrations.CreateModel( name='Heatmap', diff --git a/tests/gis_tests/gis_migrations/test_commands.py b/tests/gis_tests/gis_migrations/test_commands.py index 65bd035b8c..0846c3d8df 100644 --- a/tests/gis_tests/gis_migrations/test_commands.py +++ b/tests/gis_tests/gis_migrations/test_commands.py @@ -2,10 +2,9 @@ from __future__ import unicode_literals from django.core.management import call_command from django.db import connection -from django.test import TransactionTestCase, skipUnlessDBFeature +from django.test import TransactionTestCase -@skipUnlessDBFeature("gis_enabled") class MigrateTests(TransactionTestCase): """ Tests running the migrate command in Geodjango. diff --git a/tests/gis_tests/gis_migrations/test_operations.py b/tests/gis_tests/gis_migrations/test_operations.py index 26ff16feed..74602b761c 100644 --- a/tests/gis_tests/gis_migrations/test_operations.py +++ b/tests/gis_tests/gis_migrations/test_operations.py @@ -14,15 +14,13 @@ from django.test import ( from ..utils import mysql, spatialite -if connection.features.gis_enabled: - try: - GeometryColumns = connection.ops.geometry_columns() - HAS_GEOMETRY_COLUMNS = True - except NotImplementedError: - HAS_GEOMETRY_COLUMNS = False +try: + GeometryColumns = connection.ops.geometry_columns() + HAS_GEOMETRY_COLUMNS = True +except NotImplementedError: + HAS_GEOMETRY_COLUMNS = False -@skipUnlessDBFeature('gis_enabled') class OperationTestCase(TransactionTestCase): available_apps = ['gis_tests.gis_migrations'] diff --git a/tests/gis_tests/inspectapp/models.py b/tests/gis_tests/inspectapp/models.py index 1319ed30e4..1c37579c0a 100644 --- a/tests/gis_tests/inspectapp/models.py +++ b/tests/gis_tests/inspectapp/models.py @@ -13,15 +13,9 @@ class AllOGRFields(models.Model): geom = models.PolygonField() point = models.PointField() - class Meta: - required_db_features = ['gis_enabled'] - class Fields3D(models.Model): point = models.PointField(dim=3) pointg = models.PointField(dim=3, geography=True) line = models.LineStringField(dim=3) poly = models.PolygonField(dim=3) - - class Meta: - required_db_features = ['gis_enabled'] diff --git a/tests/gis_tests/inspectapp/tests.py b/tests/gis_tests/inspectapp/tests.py index 75865997dc..2b143fdf1b 100644 --- a/tests/gis_tests/inspectapp/tests.py +++ b/tests/gis_tests/inspectapp/tests.py @@ -20,7 +20,6 @@ if HAS_GDAL: from .models import AllOGRFields -@skipUnlessDBFeature("gis_enabled") class InspectDbTests(TestCase): def test_geom_columns(self): """ @@ -63,7 +62,6 @@ class InspectDbTests(TestCase): self.assertIn('poly = models.GeometryField(', output) -@skipUnlessDBFeature("gis_enabled") @modify_settings( INSTALLED_APPS={'append': 'django.contrib.gis'}, ) diff --git a/tests/gis_tests/layermap/models.py b/tests/gis_tests/layermap/models.py index 25dd0e4bcd..17628ffdda 100644 --- a/tests/gis_tests/layermap/models.py +++ b/tests/gis_tests/layermap/models.py @@ -8,7 +8,6 @@ class NamedModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] def __str__(self): return self.name @@ -37,7 +36,6 @@ class City(NamedModel): class Meta: app_label = 'layermap' - required_db_features = ['gis_enabled'] class Interstate(NamedModel): @@ -46,7 +44,6 @@ class Interstate(NamedModel): class Meta: app_label = 'layermap' - required_db_features = ['gis_enabled'] # Same as `City` above, but for testing model inheritance. @@ -73,9 +70,6 @@ class ICity2(ICity1): class Invalid(models.Model): point = models.PointField() - class Meta: - required_db_features = ['gis_enabled'] - # Mapping dictionaries for the models above. co_mapping = { diff --git a/tests/gis_tests/layermap/tests.py b/tests/gis_tests/layermap/tests.py index a8a352eda5..cf2c05f004 100644 --- a/tests/gis_tests/layermap/tests.py +++ b/tests/gis_tests/layermap/tests.py @@ -10,7 +10,7 @@ from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.geos import HAS_GEOS from django.db import connection -from django.test import TestCase, override_settings, skipUnlessDBFeature +from django.test import TestCase, override_settings from django.utils._os import upath if HAS_GEOS and HAS_GDAL: @@ -38,7 +38,6 @@ NUMS = [1, 2, 1, 19, 1] # Number of polygons for each. STATES = ['Texas', 'Texas', 'Texas', 'Hawaii', 'Colorado'] -@skipUnlessDBFeature("gis_enabled") class LayerMapTest(TestCase): def test_init(self): @@ -335,7 +334,6 @@ class OtherRouter(object): return True -@skipUnlessDBFeature("gis_enabled") @override_settings(DATABASE_ROUTERS=[OtherRouter()]) class LayerMapRouterTest(TestCase): diff --git a/tests/gis_tests/relatedapp/models.py b/tests/gis_tests/relatedapp/models.py index 32de25bd20..26d5369eb6 100644 --- a/tests/gis_tests/relatedapp/models.py +++ b/tests/gis_tests/relatedapp/models.py @@ -8,7 +8,6 @@ class SimpleModel(models.Model): class Meta: abstract = True - required_db_features = ['gis_enabled'] @python_2_unicode_compatible diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py index 3ca4d91dba..024c1b644a 100644 --- a/tests/gis_tests/relatedapp/tests.py +++ b/tests/gis_tests/relatedapp/tests.py @@ -14,7 +14,6 @@ from .models import ( ) -@skipUnlessDBFeature("gis_enabled") class RelatedGeoModelTest(TestCase): fixtures = ['initial'] diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py index 26a08904b3..1af555e672 100644 --- a/tests/gis_tests/test_geoforms.py +++ b/tests/gis_tests/test_geoforms.py @@ -4,12 +4,11 @@ from django.contrib.gis import forms from django.contrib.gis.forms import BaseGeometryWidget from django.contrib.gis.geos import GEOSGeometry from django.forms import ValidationError -from django.test import SimpleTestCase, override_settings, skipUnlessDBFeature +from django.test import SimpleTestCase, override_settings from django.test.utils import patch_logger from django.utils.html import escape -@skipUnlessDBFeature("gis_enabled") class GeometryFieldTest(SimpleTestCase): def test_init(self): @@ -138,7 +137,6 @@ class GeometryFieldTest(SimpleTestCase): ) -@skipUnlessDBFeature("gis_enabled") class SpecializedFieldTest(SimpleTestCase): def setUp(self): self.geometries = { @@ -310,7 +308,6 @@ class SpecializedFieldTest(SimpleTestCase): self.assertFalse(GeometryForm(data={'g': invalid.wkt}).is_valid()) -@skipUnlessDBFeature("gis_enabled") class OSMWidgetTest(SimpleTestCase): def setUp(self): self.geometries = { @@ -351,7 +348,6 @@ class OSMWidgetTest(SimpleTestCase): rendered) -@skipUnlessDBFeature("gis_enabled") class GeometryWidgetTests(SimpleTestCase): def test_get_context_attrs(self): diff --git a/tests/runtests.py b/tests/runtests.py index 6eaddbc3c5..e89ac2a258 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -84,11 +84,12 @@ CONTRIB_TESTS_TO_APPS = { def get_test_modules(): modules = [] - discovery_paths = [ - (None, RUNTESTS_DIR), + discovery_paths = [(None, RUNTESTS_DIR)] + if connection.features.gis_enabled: # GIS tests are in nested apps - ('gis_tests', os.path.join(RUNTESTS_DIR, 'gis_tests')), - ] + discovery_paths.append(('gis_tests', os.path.join(RUNTESTS_DIR, 'gis_tests'))) + else: + SUBDIRS_TO_SKIP.append('gis_tests') for modpath, dirpath in discovery_paths: for f in os.listdir(dirpath): @@ -106,6 +107,16 @@ def get_installed(): def setup(verbosity, test_labels, parallel): + # Reduce the given test labels to just the app module path. + test_labels_set = set() + for label in test_labels: + bits = label.split('.')[:1] + test_labels_set.add('.'.join(bits)) + + if 'gis_tests' in test_labels_set and not connection.features.gis_enabled: + print('Aborting: A GIS database backend is required to run gis_tests.') + sys.exit(1) + if verbosity >= 1: msg = "Testing against Django installed in '%s'" % os.path.dirname(django.__file__) max_parallel = default_test_processes() if parallel == 0 else parallel @@ -185,12 +196,6 @@ def setup(verbosity, test_labels, parallel): # Load all the test model apps. test_modules = get_test_modules() - # Reduce given test labels to just the app module path - test_labels_set = set() - for label in test_labels: - bits = label.split('.')[:1] - test_labels_set.add('.'.join(bits)) - installed_app_names = set(get_installed()) for modpath, module_name in test_modules: if modpath: