/django/contrib/gis/tests/utils.py
Python | 26 lines | 18 code | 4 blank | 4 comment | 1 complexity | f2661dee90065d6d0430bdc892ead4c6 MD5 | raw file
Possible License(s): BSD-3-Clause
1from django.conf import settings 2from django.db import DEFAULT_DB_ALIAS 3 4# function that will pass a test. 5def pass_test(*args): return 6 7def 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. 16def no_oracle(func): return no_backend(func, 'oracle') 17def no_postgis(func): return no_backend(func, 'postgis') 18def no_mysql(func): return no_backend(func, 'mysql') 19def 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] 23oracle = _default_db == 'oracle' 24postgis = _default_db == 'postgis' 25mysql = _default_db == 'mysql' 26spatialite = _default_db == 'spatialite'