Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #8047: property detect an external database backend and set sys…

….path accordingly. Patch from Leo Soto.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8238 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 176fabcc6fde81856f606b5ec44594f2a825a645 1 parent 34028f3
Jacob Kaplan-Moss jacobian authored
Showing with 17 additions and 5 deletions.
  1. +17 −5 tests/regressiontests/admin_scripts/tests.py
22 tests/regressiontests/admin_scripts/tests.py
View
@@ -67,10 +67,22 @@ def _sys_executable(self):
else:
return sys.executable
+ def _ext_backend_path(self):
+ """
+ Returns the path for the external backend package, or None if no
+ external backend is detected.
+ """
+ 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)
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()
# Remember the old environment
old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None)
@@ -82,11 +94,11 @@ def run_test(self, script, args, settings_file=None, apps=None):
os.environ['DJANGO_SETTINGS_MODULE'] = settings_file
elif 'DJANGO_SETTINGS_MODULE' in os.environ:
del os.environ['DJANGO_SETTINGS_MODULE']
-
- if old_python_path:
- os.environ['PYTHONPATH'] = os.pathsep.join([test_dir, base_dir, old_python_path])
- else:
- os.environ['PYTHONPATH'] = os.pathsep.join([test_dir, base_dir])
+ python_path = [test_dir, base_dir]
+ if ext_backend_base_dir:
+ python_path.append(ext_backend_base_dir)
+ os.environ['PYTHONPATH'] = os.pathsep.join(python_path)
+
# Build the command line
cmd = '%s "%s"' % (self._sys_executable(), script)
Please sign in to comment.
Something went wrong with that request. Please try again.