Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #8268: Modified admin scripts tests to use JYTHONPATH when appr…

…opriate. Thanks to leosoto for the patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8400 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fc2c03b55cf0a52ba4236f75acb08146283a1062 1 parent 2b82a3b
@freakboy3742 freakboy3742 authored
Showing with 13 additions and 20 deletions.
  1. +13 −20 tests/regressiontests/admin_scripts/tests.py
View
33 tests/regressiontests/admin_scripts/tests.py
@@ -42,7 +42,7 @@ def remove_settings(self, filename):
test_dir = os.path.dirname(os.path.dirname(__file__))
full_name = os.path.join(test_dir, filename)
os.remove(full_name)
-
+
# Also try to remove the compiled file; if it exists, it could
# mess up later tests that depend upon the .py file not existing
try:
@@ -54,18 +54,6 @@ def remove_settings(self, filename):
os.remove(full_name + 'c')
except OSError:
pass
-
- def _sys_executable(self):
- """
- Returns the command line needed to run a python interpreter, including
- the options for setting sys.path on Jython, which doesn't recognize
- PYTHONPATH.
- """
- if sys.platform.startswith('java'):
- return "%s -J-Dpython.path=%s" % \
- (sys.executable, os.environ['PYTHONPATH'])
- else:
- return sys.executable
def _ext_backend_path(self):
"""
@@ -78,6 +66,7 @@ def _ext_backend_path(self):
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)
@@ -86,7 +75,12 @@ def run_test(self, script, args, settings_file=None, apps=None):
# Remember the old environment
old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None)
- old_python_path = os.environ.get('PYTHONPATH', None)
+ if sys.platform.startswith('java'):
+ python_path_var_name = 'JYTHONPATH'
+ else:
+ python_path_var_name = 'PYTHONPATH'
+
+ old_python_path = os.environ.get(python_path_var_name, None)
old_cwd = os.getcwd()
# Set the test environment
@@ -97,11 +91,10 @@ def run_test(self, script, args, settings_file=None, apps=None):
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)
-
+ os.environ[python_path_var_name] = os.pathsep.join(python_path)
# Build the command line
- cmd = '%s "%s"' % (self._sys_executable(), script)
+ cmd = '%s "%s"' % (sys.executable, script)
cmd += ''.join([' %s' % arg for arg in args])
# Move to the test directory and run
@@ -118,7 +111,7 @@ def run_test(self, script, args, settings_file=None, apps=None):
if old_django_settings_module:
os.environ['DJANGO_SETTINGS_MODULE'] = old_django_settings_module
if old_python_path:
- os.environ['PYTHONPATH'] = old_python_path
+ os.environ[python_path_var_name] = old_python_path
# Move back to the old working directory
os.chdir(old_cwd)
@@ -425,7 +418,7 @@ def test_builtin_with_bad_environment(self):
self.assertNoOutput(out)
self.assertOutput(err, "Could not import settings 'bad_settings'")
- def test_custom_command(self):
+ def test_custom_command(self):
"alternate: django-admin can't execute user commands unless settings are provided"
args = ['noargs_command']
out, err = self.run_django_admin(args)
@@ -495,7 +488,7 @@ def test_builtin_with_bad_environment(self):
self.assertNoOutput(out)
self.assertOutput(err, "Could not import settings 'bad_settings'")
- def test_custom_command(self):
+ def test_custom_command(self):
"alternate: django-admin can't execute user commands unless settings are provided"
args = ['noargs_command']
out, err = self.run_django_admin(args)
Please sign in to comment.
Something went wrong with that request. Please try again.