summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2015-04-24 17:24:07 +0200
committerClaude Paroz <claude@2xlibre.net>2015-04-24 20:30:23 +0200
commitd9bcba9b29725a3b717846db651bf917630610ff (patch)
tree17ef6df42e304c3290d1d4497802046bdba0b225 /tests
parent61d09e61f5747d7a70268ca8d5e770486877500b (diff)
Removed many HAS_GEOS conditional imports
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/distapp/tests.py12
-rw-r--r--tests/gis_tests/geo3d/tests.py17
-rw-r--r--tests/gis_tests/geoadmin/tests.py11
-rw-r--r--tests/gis_tests/geoapp/test_feeds.py4
-rw-r--r--tests/gis_tests/geoapp/test_functions.py15
-rw-r--r--tests/gis_tests/geoapp/test_regress.py7
-rw-r--r--tests/gis_tests/geoapp/test_serializers.py6
-rw-r--r--tests/gis_tests/geoapp/test_sitemaps.py4
-rw-r--r--tests/gis_tests/geoapp/tests.py16
-rw-r--r--tests/gis_tests/geogapp/tests.py5
-rw-r--r--tests/gis_tests/geos_tests/test_geos.py16
-rw-r--r--tests/gis_tests/geos_tests/test_geos_mutation.py16
-rw-r--r--tests/gis_tests/geos_tests/test_io.py9
-rw-r--r--tests/gis_tests/relatedapp/tests.py14
-rw-r--r--tests/gis_tests/test_geoforms.py7
-rw-r--r--tests/gis_tests/test_geoip.py5
16 files changed, 64 insertions, 100 deletions
diff --git a/tests/gis_tests/distapp/tests.py b/tests/gis_tests/distapp/tests.py
index 6638b9ed00..c18763cad4 100644
--- a/tests/gis_tests/distapp/tests.py
+++ b/tests/gis_tests/distapp/tests.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.contrib.gis.db.models.functions import (
Area, Distance, Length, Perimeter, Transform,
)
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import GEOSGeometry, LineString, Point
from django.contrib.gis.measure import D # alias for Distance
from django.db import connection
from django.db.models import Q
@@ -11,12 +11,10 @@ from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from django.utils.deprecation import RemovedInDjango21Warning
from ..utils import no_oracle, oracle, postgis, spatialite
-
-if HAS_GEOS:
- from django.contrib.gis.geos import GEOSGeometry, LineString, Point
-
- from .models import (AustraliaCity, Interstate, SouthTexasInterstate,
- SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode)
+from .models import (
+ AustraliaCity, CensusZipcode, Interstate, SouthTexasCity, SouthTexasCityFt,
+ SouthTexasInterstate, SouthTexasZipcode,
+)
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/geo3d/tests.py b/tests/gis_tests/geo3d/tests.py
index 93c2158f6d..2feecaa417 100644
--- a/tests/gis_tests/geo3d/tests.py
+++ b/tests/gis_tests/geo3d/tests.py
@@ -4,26 +4,25 @@ import os
import re
from unittest import skipUnless
+from django.contrib.gis.db.models import Extent3D, Union
from django.contrib.gis.db.models.functions import (
AsGeoJSON, AsKML, Length, Perimeter, Scale, Translate,
)
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import GEOSGeometry, LineString, Point, Polygon
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from django.utils._os import upath
from django.utils.deprecation import (
RemovedInDjango20Warning, RemovedInDjango21Warning,
)
-if HAS_GEOS:
- from django.contrib.gis.db.models import Union, Extent3D
- from django.contrib.gis.geos import GEOSGeometry, LineString, Point, Polygon
-
- from .models import (City3D, Interstate2D, Interstate3D, InterstateProj2D,
- InterstateProj3D, Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D)
+from .models import (
+ City3D, Interstate2D, Interstate3D, InterstateProj2D, InterstateProj3D,
+ MultiPoint3D, Point2D, Point3D, Polygon2D, Polygon3D,
+)
- if HAS_GDAL:
- from django.contrib.gis.utils import LayerMapping, LayerMapError
+if HAS_GDAL:
+ from django.contrib.gis.utils import LayerMapping, LayerMapError
data_path = os.path.realpath(os.path.join(os.path.dirname(upath(__file__)), '..', 'data'))
diff --git a/tests/gis_tests/geoadmin/tests.py b/tests/gis_tests/geoadmin/tests.py
index 07af5a0d64..fc6c031dc0 100644
--- a/tests/gis_tests/geoadmin/tests.py
+++ b/tests/gis_tests/geoadmin/tests.py
@@ -1,14 +1,11 @@
from __future__ import unicode_literals
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis import admin
+from django.contrib.gis.geos import Point
from django.test import TestCase, override_settings, skipUnlessDBFeature
-if HAS_GEOS:
- from django.contrib.gis import admin
- from django.contrib.gis.geos import Point
-
- from .admin import UnmodifiableAdmin
- from .models import site, City
+from .admin import UnmodifiableAdmin
+from .models import City, site
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/geoapp/test_feeds.py b/tests/gis_tests/geoapp/test_feeds.py
index baf2051364..55c19c01c9 100644
--- a/tests/gis_tests/geoapp/test_feeds.py
+++ b/tests/gis_tests/geoapp/test_feeds.py
@@ -3,14 +3,12 @@ from __future__ import unicode_literals
from xml.dom import minidom
from django.conf import settings
-from django.contrib.gis.geos import HAS_GEOS
from django.contrib.sites.models import Site
from django.test import (
TestCase, modify_settings, override_settings, skipUnlessDBFeature,
)
-if HAS_GEOS:
- from .models import City
+from .models import City
@modify_settings(INSTALLED_APPS={'append': 'django.contrib.sites'})
diff --git a/tests/gis_tests/geoapp/test_functions.py b/tests/gis_tests/geoapp/test_functions.py
index edef090c5b..bcd9a1ccc6 100644
--- a/tests/gis_tests/geoapp/test_functions.py
+++ b/tests/gis_tests/geoapp/test_functions.py
@@ -2,21 +2,17 @@ from __future__ import unicode_literals
import re
from decimal import Decimal
-from unittest import skipUnless
from django.contrib.gis.db.models import functions
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import (
+ LineString, Point, Polygon, fromstr, geos_version_info,
+)
from django.db import connection
from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
from ..utils import mysql, oracle, postgis, spatialite
-
-if HAS_GEOS:
- from django.contrib.gis.geos import (
- LineString, Point, Polygon, fromstr, geos_version_info,
- )
- from .models import Country, City, State, Track
+from .models import City, Country, State, Track
@skipUnlessDBFeature("gis_enabled")
@@ -385,8 +381,9 @@ class GISFunctionsTests(TestCase):
)
@skipUnlessDBFeature("has_SymDifference_function")
- @skipUnless(HAS_GEOS and geos_version_info()['version'] >= '3.3.0', "GEOS >= 3.3 required")
def test_sym_difference(self):
+ if geos_version_info()['version'] < '3.3.0':
+ self.skipTest("GEOS >= 3.3 required")
geom = Point(5, 23, srid=4326)
qs = Country.objects.annotate(sym_difference=functions.SymDifference('mpoly', geom))
for country in qs:
diff --git a/tests/gis_tests/geoapp/test_regress.py b/tests/gis_tests/geoapp/test_regress.py
index e3f5437991..155126a862 100644
--- a/tests/gis_tests/geoapp/test_regress.py
+++ b/tests/gis_tests/geoapp/test_regress.py
@@ -3,16 +3,13 @@ from __future__ import unicode_literals
from datetime import datetime
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.db.models import Extent
from django.contrib.gis.shortcuts import render_to_kmz
from django.db.models import Count, Min
from django.test import TestCase, skipUnlessDBFeature
from ..utils import no_oracle
-
-if HAS_GEOS:
- from django.contrib.gis.db.models import Extent
- from .models import City, PennsylvaniaCity, State, Truth
+from .models import City, PennsylvaniaCity, State, Truth
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/geoapp/test_serializers.py b/tests/gis_tests/geoapp/test_serializers.py
index 5656ea6f4e..09f837417b 100644
--- a/tests/gis_tests/geoapp/test_serializers.py
+++ b/tests/gis_tests/geoapp/test_serializers.py
@@ -2,13 +2,11 @@ from __future__ import unicode_literals
import json
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import LinearRing, Point, Polygon
from django.core import serializers
from django.test import TestCase, skipUnlessDBFeature
-if HAS_GEOS:
- from django.contrib.gis.geos import LinearRing, Point, Polygon
- from .models import City, MultiFields, PennsylvaniaCity
+from .models import City, MultiFields, PennsylvaniaCity
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/geoapp/test_sitemaps.py b/tests/gis_tests/geoapp/test_sitemaps.py
index 416166b198..4bd8b8744e 100644
--- a/tests/gis_tests/geoapp/test_sitemaps.py
+++ b/tests/gis_tests/geoapp/test_sitemaps.py
@@ -5,7 +5,6 @@ from io import BytesIO
from xml.dom import minidom
from django.conf import settings
-from django.contrib.gis.geos import HAS_GEOS
from django.contrib.sites.models import Site
from django.test import (
TestCase, ignore_warnings, modify_settings, override_settings,
@@ -13,8 +12,7 @@ from django.test import (
)
from django.utils.deprecation import RemovedInDjango20Warning
-if HAS_GEOS:
- from .models import City, Country
+from .models import City, Country
@modify_settings(INSTALLED_APPS={'append': ['django.contrib.sites', 'django.contrib.sitemaps']})
diff --git a/tests/gis_tests/geoapp/tests.py b/tests/gis_tests/geoapp/tests.py
index 6ea20c0011..fe681f706d 100644
--- a/tests/gis_tests/geoapp/tests.py
+++ b/tests/gis_tests/geoapp/tests.py
@@ -4,7 +4,11 @@ import re
import tempfile
from django.contrib.gis import gdal
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.db.models import Extent, MakeLine, Union
+from django.contrib.gis.geos import (
+ GeometryCollection, GEOSGeometry, LinearRing, LineString, Point, Polygon,
+ fromstr,
+)
from django.core.management import call_command
from django.db import connection
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
@@ -14,12 +18,10 @@ from django.utils.deprecation import (
)
from ..utils import no_oracle, oracle, postgis, spatialite
-
-if HAS_GEOS:
- from django.contrib.gis.db.models import Extent, MakeLine, Union
- from django.contrib.gis.geos import (fromstr, GEOSGeometry,
- Point, LineString, LinearRing, Polygon, GeometryCollection)
- from .models import Country, City, PennsylvaniaCity, State, Track, NonConcreteModel, Feature, MinusOneSRID
+from .models import (
+ City, Country, Feature, MinusOneSRID, NonConcreteModel, PennsylvaniaCity,
+ State, Track,
+)
def postgis_bug_version():
diff --git a/tests/gis_tests/geogapp/tests.py b/tests/gis_tests/geogapp/tests.py
index d4f8ac3843..ec70e98d70 100644
--- a/tests/gis_tests/geogapp/tests.py
+++ b/tests/gis_tests/geogapp/tests.py
@@ -8,16 +8,13 @@ from unittest import skipUnless
from django.contrib.gis.db.models.functions import Area, Distance
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.measure import D
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango21Warning
from ..utils import oracle, postgis
-
-if HAS_GEOS:
- from .models import City, County, Zipcode
+from .models import City, County, Zipcode
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/geos_tests/test_geos.py b/tests/gis_tests/geos_tests/test_geos.py
index 9430a9b4bb..c14a2782dc 100644
--- a/tests/gis_tests/geos_tests/test_geos.py
+++ b/tests/gis_tests/geos_tests/test_geos.py
@@ -8,8 +8,14 @@ from binascii import a2b_hex, b2a_hex
from io import BytesIO
from unittest import skipUnless
+from django.contrib.gis import gdal
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import (
+ HAS_GEOS, GeometryCollection, GEOSException, GEOSGeometry, GEOSIndexError,
+ LinearRing, LineString, MultiLineString, MultiPoint, MultiPolygon, Point,
+ Polygon, fromfile, fromstr, geos_version_info,
+)
+from django.contrib.gis.geos.base import GEOSBase
from django.contrib.gis.shortcuts import numpy
from django.utils import six
from django.utils.encoding import force_bytes
@@ -17,14 +23,6 @@ from django.utils.six.moves import range
from ..test_data import TestDataMixin
-if HAS_GEOS:
- from django.contrib.gis.geos import (
- GEOSException, GEOSIndexError, GEOSGeometry, GeometryCollection, Point,
- MultiPoint, Polygon, MultiPolygon, LinearRing, LineString,
- MultiLineString, fromfile, fromstr, geos_version_info,
- )
- from django.contrib.gis.geos.base import gdal, GEOSBase
-
@skipUnless(HAS_GEOS, "Geos is required.")
class GEOSTest(unittest.TestCase, TestDataMixin):
diff --git a/tests/gis_tests/geos_tests/test_geos_mutation.py b/tests/gis_tests/geos_tests/test_geos_mutation.py
index e88339775b..51b19db9e4 100644
--- a/tests/gis_tests/geos_tests/test_geos_mutation.py
+++ b/tests/gis_tests/geos_tests/test_geos_mutation.py
@@ -5,18 +5,14 @@
import unittest
from unittest import skipUnless
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import (
+ HAS_GEOS, LinearRing, LineString, MultiPoint, Point, Polygon, fromstr,
+)
+from django.contrib.gis.geos.error import GEOSIndexError
-if HAS_GEOS:
- from django.contrib.gis.geos import (
- fromstr, LinearRing, LineString, MultiPoint, Point, Polygon,
- )
- from django.contrib.gis.geos.error import GEOSIndexError
-
-if HAS_GEOS:
- def api_get_distance(x):
- return x.distance(Point(-200, -200))
+def api_get_distance(x):
+ return x.distance(Point(-200, -200))
def api_get_buffer(x):
diff --git a/tests/gis_tests/geos_tests/test_io.py b/tests/gis_tests/geos_tests/test_io.py
index 95f84bbb4f..59cb54b6b4 100644
--- a/tests/gis_tests/geos_tests/test_io.py
+++ b/tests/gis_tests/geos_tests/test_io.py
@@ -4,14 +4,11 @@ import binascii
import unittest
from unittest import skipUnless
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import (
+ HAS_GEOS, GEOSGeometry, WKBReader, WKBWriter, WKTReader, WKTWriter,
+)
from django.utils.six import memoryview
-if HAS_GEOS:
- from django.contrib.gis.geos import (
- GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter,
- )
-
@skipUnless(HAS_GEOS, "Geos is required.")
class GEOSIOTest(unittest.TestCase):
diff --git a/tests/gis_tests/relatedapp/tests.py b/tests/gis_tests/relatedapp/tests.py
index f8e0e26105..5422dd48a7 100644
--- a/tests/gis_tests/relatedapp/tests.py
+++ b/tests/gis_tests/relatedapp/tests.py
@@ -1,6 +1,8 @@
from __future__ import unicode_literals
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.db.models import F, Collect, Count, Extent, Union
+from django.contrib.gis.geometry.backend import Geometry
+from django.contrib.gis.geos import GEOSGeometry, MultiPoint, Point
from django.db import connection
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from django.test.utils import override_settings
@@ -8,13 +10,9 @@ from django.utils import timezone
from django.utils.deprecation import RemovedInDjango20Warning
from ..utils import no_oracle
-
-if HAS_GEOS:
- from django.contrib.gis.db.models import Collect, Count, Extent, F, Union
- from django.contrib.gis.geometry.backend import Geometry
- from django.contrib.gis.geos import GEOSGeometry, Point, MultiPoint
-
- from .models import City, Location, DirectoryEntry, Parcel, Book, Author, Article, Event
+from .models import (
+ Article, Author, Book, City, DirectoryEntry, Event, Location, Parcel,
+)
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/test_geoforms.py b/tests/gis_tests/test_geoforms.py
index a7388d0353..836c720c03 100644
--- a/tests/gis_tests/test_geoforms.py
+++ b/tests/gis_tests/test_geoforms.py
@@ -1,16 +1,13 @@
from unittest import skipUnless
+from django.contrib.gis import forms
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import GEOSGeometry
from django.forms import ValidationError
from django.test import SimpleTestCase, skipUnlessDBFeature
from django.utils import six
from django.utils.html import escape
-if HAS_GEOS and HAS_GDAL:
- from django.contrib.gis import forms
- from django.contrib.gis.geos import GEOSGeometry
-
@skipUnless(HAS_GDAL, "GeometryFieldTest needs GDAL support")
@skipUnlessDBFeature("gis_enabled")
diff --git a/tests/gis_tests/test_geoip.py b/tests/gis_tests/test_geoip.py
index 91a84d42af..57647314b3 100644
--- a/tests/gis_tests/test_geoip.py
+++ b/tests/gis_tests/test_geoip.py
@@ -7,15 +7,12 @@ from unittest import skipUnless
from django.conf import settings
from django.contrib.gis.geoip import HAS_GEOIP
-from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.gis.geos import HAS_GEOS, GEOSGeometry
from django.utils import six
if HAS_GEOIP:
from django.contrib.gis.geoip import GeoIP, GeoIPException
-if HAS_GEOS:
- from django.contrib.gis.geos import GEOSGeometry
-
# Note: Requires use of both the GeoIP country and city datasets.
# The GEOIP_DATA path should be the only setting set (the directory