def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.geos import GEOS_PREPARE from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.utils import HAS_GEOIP from django.contrib.gis.tests.utils import postgis, mysql from django.db import connection from django.utils.importlib import import_module gis_tests = [] # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests gis_tests.append(geos_tests.suite()) # Tests that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] if postgis and connection.ops.geography: # Test geography support with PostGIS 1.5+. test_apps.append('geogapp') # Tests that do not require setting up and tearing down a spatial database. test_suite_names = [ 'test_measure', ] if HAS_GDAL: # These tests require GDAL. if not mysql: test_apps.append('distapp') # Only PostGIS using GEOS 3.1+ can support 3D so far. if postgis and GEOS_PREPARE: test_apps.append('geo3d') test_suite_names.extend(['test_spatialrefsys', 'test_geoforms']) test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests gis_tests.append(gdal_tests.suite()) else: print >> sys.stderr, "GDAL not available - no tests requiring GDAL will be run." if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') # Adding the rest of the suites from the modules specified # in the `test_suite_names`. for suite_name in test_suite_names: tsuite = import_module('django.contrib.gis.tests.' + suite_name) gis_tests.append(tsuite.suite()) return gis_tests, test_apps
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.geos import GEOS_PREPARE from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.utils import HAS_GEOIP from django.contrib.gis.tests.utils import postgis, mysql from django.db import connection from django.utils.importlib import import_module gis_tests = [] # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests gis_tests.append(geos_tests.suite()) # Tests that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] if postgis and connection.ops.geography: # Test geography support with PostGIS 1.5+. test_apps.append('geogapp') # Tests that do not require setting up and tearing down a spatial database. test_suite_names = [ 'test_measure', ] if HAS_GDAL: # These tests require GDAL. if not mysql: test_apps.append('distapp') # Only PostGIS using GEOS 3.1+ can support 3D so far. if postgis and GEOS_PREPARE: test_apps.append('geo3d') test_suite_names.extend(['test_spatialrefsys', 'test_geoforms']) test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests gis_tests.append(gdal_tests.suite()) else: print >>sys.stderr, "GDAL not available - no tests requiring GDAL will be run." if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') # Adding the rest of the suites from the modules specified # in the `test_suite_names`. for suite_name in test_suite_names: tsuite = import_module('django.contrib.gis.tests.' + suite_name) gis_tests.append(tsuite.suite()) return gis_tests, test_apps
def geodjango_suite(apps=True): """ Returns a TestSuite consisting only of GeoDjango tests that can be run. """ import sys from django.db.models import get_app suite = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests suite.addTest(geos_tests.suite()) # Adding GDAL tests, and any test suite that depends on GDAL, to the # suite if GDAL is available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: from django.contrib.gis.gdal import tests as gdal_tests suite.addTest(gdal_tests.suite()) else: sys.stderr.write('GDAL not available - no tests requiring GDAL will be run.\n') # Add GeoIP tests to the suite, if the library and data is available. from django.contrib.gis.geoip import HAS_GEOIP if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): from django.contrib.gis.geoip import tests as geoip_tests suite.addTest(geoip_tests.suite()) # Finally, adding the suites for each of the GeoDjango test apps. if apps: for app_name in geo_apps(namespace=False): suite.addTest(build_suite(get_app(app_name))) return suite
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.utils import HAS_GEOIP from django.contrib.gis.tests.utils import mysql # The test suite. s = unittest.TestSuite() # Tests that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] # Tests that do not require setting up and tearing down a spatial database. test_suite_names = [ 'test_measure', ] # Tests applications that require a test spatial db. if not mysql: test_apps.append('distapp') if HAS_GDAL: # These tests require GDAL. test_suite_names.append('test_spatialrefsys') test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests s.addTest(gdal_tests.suite()) else: print >>sys.stderr, "GDAL not available - no tests requiring GDAL will be run." if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') # Adding the rest of the suites from the modules specified # in the `test_suite_names`. for suite_name in test_suite_names: tsuite = import_module('django.contrib.gis.tests.' + suite_name) s.addTest(tsuite.suite()) # Adding the GEOS tests _last_. Doing this because if suite starts # immediately with this test while after running syncdb, it will cause a # segmentation fault. My initial guess is that SpatiaLite is still in # critical areas of non thread-safe GEOS code when the test suite is run. # TODO: Confirm my reasoning. Are there other consequences? from django.contrib.gis.geos import tests as geos_tests s.addTest(geos_tests.suite()) return s, test_apps
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.utils import HAS_GEOIP from django.contrib.gis.tests.utils import mysql # The test suite. s = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests s.addTest(geos_tests.suite()) # Tests that require use of a spatial database (e.g., creation of models) test_apps = ["geoapp", "relatedapp"] # Tests that do not require setting up and tearing down a spatial database. test_suite_names = ["test_measure"] # Tests applications that require a test spatial db. if not mysql: test_apps.append("distapp") if HAS_GDAL: # These tests require GDAL. test_suite_names.extend(["test_spatialrefsys", "test_geoforms"]) test_apps.append("layermap") # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests s.addTest(gdal_tests.suite()) else: print >>sys.stderr, "GDAL not available - no tests requiring GDAL will be run." if HAS_GEOIP and hasattr(settings, "GEOIP_PATH"): test_suite_names.append("test_geoip") # Adding the rest of the suites from the modules specified # in the `test_suite_names`. for suite_name in test_suite_names: tsuite = import_module("django.contrib.gis.tests." + suite_name) s.addTest(tsuite.suite()) return s, test_apps
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.utils import HAS_GEOIP from django.contrib.gis.tests.utils import mysql # The test suite. s = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests s.addTest(geos_tests.suite()) # Tests that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] # Tests that do not require setting up and tearing down a spatial database. test_suite_names = [ 'test_measure', ] # Tests applications that require a test spatial db. if not mysql: test_apps.append('distapp') if HAS_GDAL: # These tests require GDAL. test_suite_names.extend(['test_spatialrefsys', 'test_geoforms']) test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests s.addTest(gdal_tests.suite()) else: print >> sys.stderr, "GDAL not available - no tests requiring GDAL will be run." if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') # Adding the rest of the suites from the modules specified # in the `test_suite_names`. for suite_name in test_suite_names: tsuite = import_module('django.contrib.gis.tests.' + suite_name) s.addTest(tsuite.suite()) return s, test_apps
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.tests.utils import mysql, oracle, postgis from django.contrib.gis import gdal, utils # The test suite. s = unittest.TestSuite() # Adding the GEOS tests. (__future__) #from django.contrib.gis.geos import tests as geos_tests #s.addTest(geos_tests.suite()) # Test apps that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] if oracle or postgis: test_apps.append('distapp') # Tests that do not require setting up and tearing down a spatial database # and are modules in `django.contrib.gis.tests`. test_suite_names = [ 'test_geos', 'test_measure', ] if gdal.HAS_GDAL: # These tests require GDAL. test_suite_names.append('test_spatialrefsys') test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests s.addTest(gdal_tests.suite()) else: print >> sys.stderr, "GDAL not available - no GDAL tests will be run." if utils.HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') for suite_name in test_suite_names: tsuite = getattr( __import__('django.contrib.gis.tests', globals(), locals(), [suite_name]), suite_name) s.addTest(tsuite.suite()) return s, test_apps
def geo_suite(): """ Builds a test suite for the GIS package. This is not named `suite` so it will not interfere with the Django test suite (since spatial database tables are required to execute these tests on some backends). """ from django.conf import settings from django.contrib.gis.tests.utils import mysql, oracle, postgis from django.contrib.gis import gdal, utils # The test suite. s = unittest.TestSuite() # Adding the GEOS tests. (__future__) #from django.contrib.gis.geos import tests as geos_tests #s.addTest(geos_tests.suite()) # Test apps that require use of a spatial database (e.g., creation of models) test_apps = ['geoapp', 'relatedapp'] if oracle or postgis: test_apps.append('distapp') # Tests that do not require setting up and tearing down a spatial database # and are modules in `django.contrib.gis.tests`. test_suite_names = [ 'test_geos', 'test_measure', ] if gdal.HAS_GDAL: # These tests require GDAL. test_suite_names.append('test_spatialrefsys') test_apps.append('layermap') # Adding the GDAL tests. from django.contrib.gis.gdal import tests as gdal_tests s.addTest(gdal_tests.suite()) else: print >>sys.stderr, "GDAL not available - no GDAL tests will be run." if utils.HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): test_suite_names.append('test_geoip') for suite_name in test_suite_names: tsuite = getattr(__import__('django.contrib.gis.tests', globals(), locals(), [suite_name]), suite_name) s.addTest(tsuite.suite()) return s, test_apps
def build_suite(self, test_labels, extra_tests=None, **kwargs): """ This method is overridden to construct a suite consisting only of tests for GeoDjango. """ suite = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests suite.addTest(geos_tests.suite()) # Adding the measurment tests. from django.contrib.gis.tests import test_measure suite.addTest(test_measure.suite()) # Adding GDAL tests, and any test suite that depends on GDAL, to the # suite if GDAL is available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: from django.contrib.gis.gdal import tests as gdal_tests suite.addTest(gdal_tests.suite()) from django.contrib.gis.tests import test_spatialrefsys, test_geoforms suite.addTest(test_spatialrefsys.suite()) suite.addTest(test_geoforms.suite()) else: sys.stderr.write("GDAL not available - no tests requiring GDAL will be run.\n") # Add GeoIP tests to the suite, if the library and data is available. from django.contrib.gis.utils import HAS_GEOIP if HAS_GEOIP and hasattr(settings, "GEOIP_PATH"): from django.contrib.gis.tests import test_geoip suite.addTest(test_geoip.suite()) # Finally, adding the suites for each of the GeoDjango test apps. for app_name in self.geo_apps: suite.addTest(build_suite(get_app(app_name))) return suite
def geodjango_suite(apps=True): """ Returns a TestSuite consisting only of GeoDjango tests that can be run. """ import sys from django.db.models import get_app suite = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests suite.addTest(geos_tests.suite()) # Adding the measurment tests. from django.contrib.gis.tests import test_measure suite.addTest(test_measure.suite()) # Adding GDAL tests, and any test suite that depends on GDAL, to the # suite if GDAL is available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: from django.contrib.gis.gdal import tests as gdal_tests suite.addTest(gdal_tests.suite()) from django.contrib.gis.tests import test_spatialrefsys, test_geoforms suite.addTest(test_spatialrefsys.suite()) suite.addTest(test_geoforms.suite()) else: sys.stderr.write( 'GDAL not available - no tests requiring GDAL will be run.\n') # Add GeoIP tests to the suite, if the library and data is available. from django.contrib.gis.utils import HAS_GEOIP if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): from django.contrib.gis.tests import test_geoip suite.addTest(test_geoip.suite()) # Finally, adding the suites for each of the GeoDjango test apps. if apps: for app_name in geo_apps(namespace=False): suite.addTest(build_suite(get_app(app_name))) return suite
def build_suite(self, test_labels, extra_tests=None, **kwargs): """ This method is overridden to construct a suite consisting only of tests for GeoDjango. """ suite = unittest.TestSuite() # Adding the GEOS tests. from django.contrib.gis.geos import tests as geos_tests suite.addTest(geos_tests.suite()) # Adding the measurment tests. from django.contrib.gis.tests import test_measure suite.addTest(test_measure.suite()) # Adding GDAL tests, and any test suite that depends on GDAL, to the # suite if GDAL is available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: from django.contrib.gis.gdal import tests as gdal_tests suite.addTest(gdal_tests.suite()) from django.contrib.gis.tests import test_spatialrefsys, test_geoforms suite.addTest(test_spatialrefsys.suite()) suite.addTest(test_geoforms.suite()) else: sys.stderr.write( 'GDAL not available - no tests requiring GDAL will be run.\n') # Add GeoIP tests to the suite, if the library and data is available. from django.contrib.gis.utils import HAS_GEOIP if HAS_GEOIP and hasattr(settings, 'GEOIP_PATH'): from django.contrib.gis.tests import test_geoip suite.addTest(test_geoip.suite()) # Finally, adding the suites for each of the GeoDjango test apps. for app_name in self.geo_apps: suite.addTest(build_suite(get_app(app_name))) return suite