mirror of https://github.com/django/django.git
Skipped PostGIS version tests when psycopg2 not installed
Refs #22334. Thanks Tim Graham for spotting the issue.
This commit is contained in:
parent
88f1e3d93d
commit
e819a3cd62
|
@ -1,32 +1,39 @@
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.db import ProgrammingError
|
from django.db import ProgrammingError
|
||||||
|
|
||||||
|
try:
|
||||||
class FakeConnection(object):
|
from django.contrib.gis.db.backends.postgis.operations import PostGISOperations
|
||||||
def __init__(self):
|
HAS_POSTGRES = True
|
||||||
self.settings_dict = {
|
except ImportError:
|
||||||
'NAME': 'test',
|
HAS_POSTGRES = False
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class FakePostGISOperations(PostGISOperations):
|
if HAS_POSTGRES:
|
||||||
def __init__(self, version=None):
|
class FakeConnection(object):
|
||||||
self.version = version
|
def __init__(self):
|
||||||
self.connection = FakeConnection()
|
self.settings_dict = {
|
||||||
|
'NAME': 'test',
|
||||||
|
}
|
||||||
|
|
||||||
def _get_postgis_func(self, func):
|
|
||||||
if func == 'postgis_lib_version':
|
class FakePostGISOperations(PostGISOperations):
|
||||||
if self.version is None:
|
def __init__(self, version=None):
|
||||||
raise ProgrammingError
|
self.version = version
|
||||||
|
self.connection = FakeConnection()
|
||||||
|
|
||||||
|
def _get_postgis_func(self, func):
|
||||||
|
if func == 'postgis_lib_version':
|
||||||
|
if self.version is None:
|
||||||
|
raise ProgrammingError
|
||||||
|
else:
|
||||||
|
return self.version
|
||||||
else:
|
else:
|
||||||
return self.version
|
raise NotImplementedError('This function was not expected to be called')
|
||||||
else:
|
|
||||||
raise NotImplementedError('This function was not expected to be called')
|
|
||||||
|
|
||||||
|
|
||||||
|
@unittest.skipUnless(HAS_POSTGRES, "The psycopg2 driver is needed for these tests")
|
||||||
class TestPostgisVersionCheck(unittest.TestCase):
|
class TestPostgisVersionCheck(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
Tests that the postgis version check parses correctly the version numbers
|
Tests that the postgis version check parses correctly the version numbers
|
||||||
|
|
Loading…
Reference in New Issue