diff -r 6459429f18fb tests/regressiontests/admin_scripts/tests.py
a
|
b
|
|
42 | 42 | test_dir = os.path.dirname(os.path.dirname(__file__)) |
43 | 43 | full_name = os.path.join(test_dir, filename) |
44 | 44 | os.remove(full_name) |
45 | | |
| 45 | |
46 | 46 | # Also try to remove the compiled file; if it exists, it could |
47 | 47 | # mess up later tests that depend upon the .py file not existing |
48 | 48 | try: |
… |
… |
|
54 | 54 | os.remove(full_name + 'c') |
55 | 55 | except OSError: |
56 | 56 | pass |
57 | | |
| 57 | |
58 | 58 | def _sys_executable(self): |
59 | 59 | """ |
60 | 60 | Returns the command line needed to run a python interpreter, including |
… |
… |
|
67 | 67 | else: |
68 | 68 | return sys.executable |
69 | 69 | |
| 70 | def _ext_backend_path(self): |
| 71 | """ |
| 72 | Returns the path for the external backend package, or None if no |
| 73 | external backend is detected. |
| 74 | """ |
| 75 | first_package_re = re.compile(r'(^[^\.]+)\.') |
| 76 | result = first_package_re.findall(settings.DATABASE_ENGINE) |
| 77 | if result: |
| 78 | backend_pkg = __import__(result[0]) |
| 79 | backend_dir = os.path.dirname(backend_pkg.__file__) |
| 80 | return os.path.dirname(backend_dir) |
70 | 81 | def run_test(self, script, args, settings_file=None, apps=None): |
71 | 82 | test_dir = os.path.dirname(os.path.dirname(__file__)) |
72 | 83 | project_dir = os.path.dirname(test_dir) |
73 | 84 | base_dir = os.path.dirname(project_dir) |
| 85 | ext_backend_base_dir = self._ext_backend_path() |
74 | 86 | |
75 | 87 | # Remember the old environment |
76 | 88 | old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None) |
… |
… |
|
82 | 94 | os.environ['DJANGO_SETTINGS_MODULE'] = settings_file |
83 | 95 | elif 'DJANGO_SETTINGS_MODULE' in os.environ: |
84 | 96 | del os.environ['DJANGO_SETTINGS_MODULE'] |
85 | | |
86 | | if old_python_path: |
87 | | os.environ['PYTHONPATH'] = os.pathsep.join([test_dir, base_dir, old_python_path]) |
88 | | else: |
89 | | os.environ['PYTHONPATH'] = os.pathsep.join([test_dir, base_dir]) |
| 97 | python_path = [test_dir, base_dir] |
| 98 | if ext_backend_base_dir: |
| 99 | python_path.append(ext_backend_base_dir) |
| 100 | os.environ['PYTHONPATH'] = os.pathsep.join(python_path) |
| 101 | |
90 | 102 | |
91 | 103 | # Build the command line |
92 | 104 | cmd = '%s "%s"' % (self._sys_executable(), script) |