web/lib/django/contrib/gis/tests/utils.py
changeset 38 77b6da96e6f1
equal deleted inserted replaced
37:8d941af65caf 38:77b6da96e6f1
       
     1 from django.conf import settings
       
     2 from django.db import DEFAULT_DB_ALIAS
       
     3 
       
     4 # function that will pass a test.
       
     5 def pass_test(*args): return
       
     6 
       
     7 def no_backend(test_func, backend):
       
     8     "Use this decorator to disable test on specified backend."
       
     9     if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend:
       
    10         return pass_test
       
    11     else:
       
    12         return test_func
       
    13 
       
    14 # Decorators to disable entire test functions for specific
       
    15 # spatial backends.
       
    16 def no_oracle(func): return no_backend(func, 'oracle')
       
    17 def no_postgis(func): return no_backend(func, 'postgis')
       
    18 def no_mysql(func): return no_backend(func, 'mysql')
       
    19 def no_spatialite(func): return no_backend(func, 'spatialite')
       
    20 
       
    21 # Shortcut booleans to omit only portions of tests.
       
    22 _default_db = settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1]
       
    23 oracle  = _default_db == 'oracle'
       
    24 postgis = _default_db == 'postgis'
       
    25 mysql   = _default_db == 'mysql'
       
    26 spatialite = _default_db == 'spatialite'