<s> import unittest <EOL> from django . conf import settings <EOL> from django . test . simple import build_suite , DjangoTestSuiteRunner <EOL> def run_tests ( * args , ** kwargs ) : <EOL> from django . test . simple import run_tests as base_run_tests <EOL> return base_run_tests ( * args , ** kwargs ) <EOL> def run_gis_tests ( test_labels , verbosity = <NUM_LIT:1> , interactive = True , failfast = False , extra_tests = None ) : <EOL> import warnings <EOL> warnings . warn ( <EOL> '<STR_LIT>' , <EOL> PendingDeprecationWarning <EOL> ) <EOL> test_runner = GeoDjangoTestSuiteRunner ( verbosity = verbosity , interactive = interactive , failfast = failfast ) <EOL> return test_runner . run_tests ( test_labels , extra_tests = extra_tests ) <EOL> def geo_apps ( namespace = True , runtests = False ) : <EOL> """<STR_LIT>""" <EOL> from django . db import connection <EOL> from django . contrib . gis . geos import GEOS_PREPARE <EOL> from django . contrib . gis . gdal import HAS_GDAL <EOL> apps = [ '<STR_LIT>' , '<STR_LIT>' ] <EOL> if not connection . ops . mysql : <EOL> apps . append ( '<STR_LIT>' ) <EOL> if connection . ops . postgis and connection . ops . geography : <EOL> apps . append ( '<STR_LIT>' ) <EOL> if HAS_GDAL : <EOL> if connection . ops . postgis and GEOS_PREPARE : <EOL> apps . append ( '<STR_LIT>' ) <EOL> apps . append ( '<STR_LIT>' ) <EOL> if runtests : <EOL> return [ ( '<STR_LIT>' , app ) for app in apps ] <EOL> elif namespace : <EOL> return [ '<STR_LIT>' % app <EOL> for app in apps ] <EOL> else : <EOL> return apps <EOL> def geodjango_suite ( apps = True ) : <EOL> """<STR_LIT>""" <EOL> import sys <EOL> from django . db . models import get_app <EOL> suite = unittest . TestSuite ( ) <EOL> from django . contrib . gis . geos import tests as geos_tests <EOL> suite . addTest ( geos_tests . suite ( ) ) <EOL> from django . contrib . gis . tests import test_measure <EOL> suite . addTest ( test_measure . suite ( ) ) <EOL> from django . contrib . gis . gdal import HAS_GDAL <EOL> if HAS_GDAL : <EOL> from django . contrib . gis . gdal import tests as gdal_tests <EOL> suite . addTest ( gdal_tests . suite ( ) ) <EOL> from django . contrib . gis . tests import test_spatialrefsys , test_geoforms <EOL> suite . addTest ( test_spatialrefsys . suite ( ) ) <EOL> suite . addTest ( test_geoforms . suite ( ) ) <EOL> else : <EOL> sys . stderr . write ( '<STR_LIT>' ) <EOL> from django . contrib . gis . utils import HAS_GEOIP <EOL> if HAS_GEOIP and hasattr ( settings , '<STR_LIT>' ) : <EOL> from django . contrib . gis . tests import test_geoip <EOL> suite . addTest ( test_geoip . suite ( ) ) <EOL> if apps : <EOL> for app_name in geo_apps ( namespace = False ) : <EOL> suite . addTest ( build_suite ( get_app ( app_name ) ) ) <EOL> return suite <EOL> class GeoDjangoTestSuiteRunner ( DjangoTestSuiteRunner ) : <EOL> def setup_test_environment ( self , ** kwargs ) : <EOL> super ( GeoDjangoTestSuiteRunner , self ) . setup_test_environment ( ** kwargs ) <EOL> self . old_installed = getattr ( settings , '<STR_LIT>' , None ) <EOL> self . old_root_urlconf = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . old_site_id = getattr ( settings , '<STR_LIT>' , None ) <EOL> new_installed = [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> new_installed . extend ( geo_apps ( ) ) <EOL> settings . INSTALLED_APPS = new_installed <EOL> settings . SITE_ID = <NUM_LIT:1> <EOL> settings . ROOT_URLCONF = '<STR_LIT>' <EOL> def teardown_test_environment ( self , ** kwargs ) : <EOL> super ( GeoDjangoTestSuiteRunner , self ) . teardown_test_environment ( ** kwargs ) <EOL> settings . INSTALLED_APPS = self . old_installed <EOL> settings . ROOT_URLCONF = self . old_root_urlconf <EOL> settings . SITE_ID = self . old_site_id <EOL> def build_suite ( self , test_labels , extra_tests = None , ** kwargs ) : <EOL> return geodjango_suite ( ) </s>
