diff -r d49003a461ad 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 | | |
58 | | def _sys_executable(self): |
59 | | """ |
60 | | Returns the command line needed to run a python interpreter, including |
61 | | the options for setting sys.path on Jython, which doesn't recognize |
62 | | PYTHONPATH. |
63 | | """ |
64 | | if sys.platform.startswith('java'): |
65 | | return "%s -J-Dpython.path=%s" % \ |
66 | | (sys.executable, os.environ['PYTHONPATH']) |
67 | | else: |
68 | | return sys.executable |
69 | 57 | |
70 | 58 | def _ext_backend_path(self): |
71 | 59 | """ |
… |
… |
|
86 | 74 | |
87 | 75 | # Remember the old environment |
88 | 76 | old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None) |
89 | | old_python_path = os.environ.get('PYTHONPATH', None) |
| 77 | if sys.platform.startswith('java'): |
| 78 | python_path_var_name = 'JYTHONPATH' |
| 79 | else: |
| 80 | python_path_var_name = 'PYTHONPATH' |
| 81 | |
| 82 | old_python_path = os.environ.get(python_path_var_name, None) |
90 | 83 | old_cwd = os.getcwd() |
91 | 84 | |
92 | 85 | # Set the test environment |
… |
… |
|
97 | 90 | python_path = [test_dir, base_dir] |
98 | 91 | if ext_backend_base_dir: |
99 | 92 | python_path.append(ext_backend_base_dir) |
100 | | os.environ['PYTHONPATH'] = os.pathsep.join(python_path) |
101 | | |
| 93 | os.environ[python_path_var_name] = os.pathsep.join(python_path) |
102 | 94 | |
103 | 95 | # Build the command line |
104 | | cmd = '%s "%s"' % (self._sys_executable(), script) |
| 96 | cmd = '%s "%s"' % (sys.executable, script) |
105 | 97 | cmd += ''.join([' %s' % arg for arg in args]) |
106 | 98 | |
107 | 99 | # Move to the test directory and run |
… |
… |
|
118 | 110 | if old_django_settings_module: |
119 | 111 | os.environ['DJANGO_SETTINGS_MODULE'] = old_django_settings_module |
120 | 112 | if old_python_path: |
121 | | os.environ['PYTHONPATH'] = old_python_path |
| 113 | os.environ[python_path_var_name] = old_python_path |
122 | 114 | # Move back to the old working directory |
123 | 115 | os.chdir(old_cwd) |
124 | 116 | |
… |
… |
|
425 | 417 | self.assertNoOutput(out) |
426 | 418 | self.assertOutput(err, "Could not import settings 'bad_settings'") |
427 | 419 | |
428 | | def test_custom_command(self): |
| 420 | def test_custom_command(self): |
429 | 421 | "alternate: django-admin can't execute user commands unless settings are provided" |
430 | 422 | args = ['noargs_command'] |
431 | 423 | out, err = self.run_django_admin(args) |
… |
… |
|
495 | 487 | self.assertNoOutput(out) |
496 | 488 | self.assertOutput(err, "Could not import settings 'bad_settings'") |
497 | 489 | |
498 | | def test_custom_command(self): |
| 490 | def test_custom_command(self): |
499 | 491 | "alternate: django-admin can't execute user commands unless settings are provided" |
500 | 492 | args = ['noargs_command'] |
501 | 493 | out, err = self.run_django_admin(args) |