summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBaptiste Mispelon <bmispelon@gmail.com>2014-05-17 14:59:06 +0200
committerBaptiste Mispelon <bmispelon@gmail.com>2014-05-17 15:01:06 +0200
commita0d5970d4483920993c09617d3c7f632af6da19c (patch)
treeb07aabe68da7ee94398da77430cb5d5a30aaac19
parent5b185ecc68c04c0ee63cf44de43d831623daa263 (diff)
Fixed contrib.gis tests breaking in some edge cases.
The tests would error out with an ImproperlyConfigured error if the user had psycopg installed but not geos. Thanks to mcgohier for the report.
-rw-r--r--django/contrib/gis/tests/tests.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/django/contrib/gis/tests/tests.py b/django/contrib/gis/tests/tests.py
index 9a4c2bcbdd..cc52d2429b 100644
--- a/django/contrib/gis/tests/tests.py
+++ b/django/contrib/gis/tests/tests.py
@@ -1,13 +1,25 @@
+import sys
import unittest
from django.core.exceptions import ImproperlyConfigured
from django.db import ProgrammingError
+from django.utils import six
try:
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
HAS_POSTGRES = True
except ImportError:
HAS_POSTGRES = False
+except ImproperlyConfigured as e:
+ # If psycopg is installed but not geos, the import path hits
+ # django.contrib.gis.geometry.backend which will "helpfully" convert
+ # an ImportError into an ImproperlyConfigured.
+ # Here, we make sure we're only catching this specific case and not another
+ # ImproperlyConfigured one.
+ if e.args and e.args[0].startswith('Could not import user-defined GEOMETRY_BACKEND'):
+ HAS_POSTGRES = False
+ else:
+ six.reraise(*sys.exc_info())
if HAS_POSTGRES: