summaryrefslogtreecommitdiff
path: root/tests/regressiontests/admin_scripts/tests.py
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2009-12-22 15:18:51 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2009-12-22 15:18:51 +0000
commitff60c5f9de3e8690d1e86f3e9e3f7248a15397c8 (patch)
treea4cb0ebdd55fcaf8c8855231b6ad3e1a7bf45bee /tests/regressiontests/admin_scripts/tests.py
parent7ef212af149540aa2da577a960d0d87029fd1514 (diff)
Fixed #1142 -- Added multiple database support.
This monster of a patch is the result of Alex Gaynor's 2009 Google Summer of Code project. Congratulations to Alex for a job well done. Big thanks also go to: * Justin Bronn for keeping GIS in line with the changes, * Karen Tracey and Jani Tiainen for their help testing Oracle support * Brett Hoerner, Jon Loyens, and Craig Kimmerer for their feedback. * Malcolm Treddinick for his guidance during the GSoC submission process. * Simon Willison for driving the original design process * Cal Henderson for complaining about ponies he wanted. ... and everyone else too numerous to mention that helped to bring this feature into fruition. git-svn-id: http://code.djangoproject.com/svn/django/trunk@11952 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/admin_scripts/tests.py')
-rw-r--r--tests/regressiontests/admin_scripts/tests.py39
1 files changed, 19 insertions, 20 deletions
diff --git a/tests/regressiontests/admin_scripts/tests.py b/tests/regressiontests/admin_scripts/tests.py
index e67126e9a7..cdc9556afe 100644
--- a/tests/regressiontests/admin_scripts/tests.py
+++ b/tests/regressiontests/admin_scripts/tests.py
@@ -23,17 +23,15 @@ class AdminScriptTestCase(unittest.TestCase):
settings_file = open(os.path.join(test_dir, filename), 'w')
settings_file.write('# Settings file automatically generated by regressiontests.admin_scripts test case\n')
exports = [
- 'DATABASE_ENGINE',
- 'DATABASE_NAME',
- 'DATABASE_USER',
- 'DATABASE_PASSWORD',
- 'DATABASE_HOST',
- 'DATABASE_PORT',
+ 'DATABASES',
'ROOT_URLCONF'
]
for s in exports:
- if hasattr(settings,s):
- settings_file.write("%s = '%s'\n" % (s, str(getattr(settings,s))))
+ if hasattr(settings, s):
+ o = getattr(settings, s)
+ if not isinstance(o, dict):
+ o = "'%s'" % o
+ settings_file.write("%s = %s\n" % (s, o))
if apps is None:
apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'admin_scripts']
@@ -63,23 +61,25 @@ class AdminScriptTestCase(unittest.TestCase):
except OSError:
pass
- def _ext_backend_path(self):
+ def _ext_backend_paths(self):
"""
- Returns the path for the external backend package, or None if no
- external backend is detected.
+ Returns the paths for any external backend packages.
"""
+ paths = []
first_package_re = re.compile(r'(^[^\.]+)\.')
- result = first_package_re.findall(settings.DATABASE_ENGINE)
- if result:
- backend_pkg = __import__(result[0])
- backend_dir = os.path.dirname(backend_pkg.__file__)
- return os.path.dirname(backend_dir)
+ for backend in settings.DATABASES.values():
+ result = first_package_re.findall(backend['ENGINE'])
+ if result and result != 'django':
+ backend_pkg = __import__(result[0])
+ backend_dir = os.path.dirname(backend_pkg.__file__)
+ paths.append(os.path.dirname(backend_dir))
+ return paths
def run_test(self, script, args, settings_file=None, apps=None):
test_dir = os.path.dirname(os.path.dirname(__file__))
project_dir = os.path.dirname(test_dir)
base_dir = os.path.dirname(project_dir)
- ext_backend_base_dir = self._ext_backend_path()
+ ext_backend_base_dirs = self._ext_backend_paths()
# Remember the old environment
old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None)
@@ -97,8 +97,7 @@ class AdminScriptTestCase(unittest.TestCase):
elif 'DJANGO_SETTINGS_MODULE' in os.environ:
del os.environ['DJANGO_SETTINGS_MODULE']
python_path = [test_dir, base_dir]
- if ext_backend_base_dir:
- python_path.append(ext_backend_base_dir)
+ python_path.extend(ext_backend_base_dirs)
os.environ[python_path_var_name] = os.pathsep.join(python_path)
# Build the command line
@@ -523,7 +522,7 @@ class DjangoAdminSettingsDirectory(AdminScriptTestCase):
A series of tests for django-admin.py when the settings file is in a
directory. (see #9751).
"""
-
+
def setUp(self):
self.write_settings('settings', is_dir=True)