diff -r 184be4897104 -r 2bb0b29055aa tests/regressiontests/admin_scripts/tests.py
a
|
b
|
|
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 | def try_remove(name): |
| 49 | try: |
48 | 50 | try: |
49 | 51 | if sys.platform.startswith('java'): |
50 | 52 | # Jython produces module$py.class files |
… |
… |
|
52 | 54 | else: |
53 | 55 | # CPython produces module.pyc files |
54 | 56 | os.remove(full_name + 'c') |
55 | | except OSError: |
56 | | pass |
| 57 | except OSError: |
| 58 | pass |
57 | 59 | |
58 | 60 | def _sys_executable(self): |
59 | 61 | """ |
… |
… |
|
67 | 69 | else: |
68 | 70 | return sys.executable |
69 | 71 | |
| 72 | def _ext_backend_path(self): |
| 73 | """ |
| 74 | Returns the path for the external backend package, or None if no |
| 75 | external backend is detected. |
| 76 | """ |
| 77 | first_package_re = re.compile(r'(^[^\.]+)\.') |
| 78 | result = first_package_re.findall(settings.DATABASE_ENGINE) |
| 79 | if result: |
| 80 | backend_pkg = __import__(result[0]) |
| 81 | backend_dir = os.path.dirname(backend_pkg.__file__) |
| 82 | return os.path.dirname(backend_dir) |
70 | 83 | def run_test(self, script, args, settings_file=None, apps=None): |
71 | 84 | test_dir = os.path.dirname(os.path.dirname(__file__)) |
72 | 85 | project_dir = os.path.dirname(test_dir) |
73 | 86 | base_dir = os.path.dirname(project_dir) |
74 | | |
| 87 | ext_backend_base_dir = self._ext_backend_path() |
75 | 88 | # Remember the old environment |
76 | 89 | old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None) |
77 | 90 | old_python_path = os.environ.get('PYTHONPATH', None) |
… |
… |
|
82 | 95 | os.environ['DJANGO_SETTINGS_MODULE'] = settings_file |
83 | 96 | elif 'DJANGO_SETTINGS_MODULE' in os.environ: |
84 | 97 | 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]) |
| 98 | python_path = [test_dir, base_dir] |
| 99 | if ext_backend_base_dir: |
| 100 | python_path.append(ext_backend_base_dir) |
| 101 | os.environ['PYTHONPATH'] = os.pathsep.join(python_path) |
| 102 | |
90 | 103 | |
91 | 104 | # Build the command line |
92 | 105 | cmd = '%s "%s"' % (self._sys_executable(), script) |