~ubuntu-branches/ubuntu/quantal/python-django/quantal-security

« back to all changes in this revision

Viewing changes to django/contrib/gis/tests/utils.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.conf import settings
 
2
from django.db import DEFAULT_DB_ALIAS
2
3
 
3
4
# function that will pass a test.
4
5
def pass_test(*args): return
5
6
 
6
7
def no_backend(test_func, backend):
7
8
    "Use this decorator to disable test on specified backend."
8
 
    if settings.DATABASE_ENGINE == backend:
 
9
    if settings.DATABASES[DEFAULT_DB_ALIAS]['ENGINE'].rsplit('.')[-1] == backend:
9
10
        return pass_test
10
11
    else:
11
12
        return test_func
13
14
# Decorators to disable entire test functions for specific
14
15
# spatial backends.
15
16
def no_oracle(func): return no_backend(func, 'oracle')
16
 
def no_postgis(func): return no_backend(func, 'postgresql_psycopg2')
 
17
def no_postgis(func): return no_backend(func, 'postgis')
17
18
def no_mysql(func): return no_backend(func, 'mysql')
18
 
def no_spatialite(func): return no_backend(func, 'sqlite3')
 
19
def no_spatialite(func): return no_backend(func, 'spatialite')
19
20
 
20
21
# Shortcut booleans to omit only portions of tests.
21
 
oracle  = settings.DATABASE_ENGINE == 'oracle'
22
 
postgis = settings.DATABASE_ENGINE == 'postgresql_psycopg2' 
23
 
mysql   = settings.DATABASE_ENGINE == 'mysql'
24
 
spatialite = settings.DATABASE_ENGINE == 'sqlite3'
 
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'