Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
Russell Keith-Magee authored August 16, 2008
33  tests/regressiontests/admin_scripts/tests.py
@@ -42,7 +42,7 @@ def remove_settings(self, filename):
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,18 +54,6 @@ def remove_settings(self, filename):
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
         """
@@ -78,6 +66,7 @@ def _ext_backend_path(self):
78 66
             backend_pkg = __import__(result[0])
79 67
             backend_dir = os.path.dirname(backend_pkg.__file__)
80 68
             return os.path.dirname(backend_dir)
  69
+
81 70
     def run_test(self, script, args, settings_file=None, apps=None):
82 71
         test_dir = os.path.dirname(os.path.dirname(__file__))
83 72
         project_dir = os.path.dirname(test_dir)
@@ -86,7 +75,12 @@ def run_test(self, script, args, settings_file=None, apps=None):
86 75
 
87 76
         # Remember the old environment
88 77
         old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None)
89  
-        old_python_path = os.environ.get('PYTHONPATH', None)
  78
+        if sys.platform.startswith('java'):
  79
+            python_path_var_name = 'JYTHONPATH'
  80
+        else:
  81
+            python_path_var_name = 'PYTHONPATH'
  82
+
  83
+        old_python_path = os.environ.get(python_path_var_name, None)
90 84
         old_cwd = os.getcwd()
91 85
 
92 86
         # Set the test environment
@@ -97,11 +91,10 @@ def run_test(self, script, args, settings_file=None, apps=None):
97 91
         python_path = [test_dir, base_dir]
98 92
         if ext_backend_base_dir:
99 93
             python_path.append(ext_backend_base_dir)
100  
-        os.environ['PYTHONPATH'] = os.pathsep.join(python_path)
101  
-
  94
+        os.environ[python_path_var_name] = os.pathsep.join(python_path)
102 95
 
103 96
         # Build the command line
104  
-        cmd = '%s "%s"' % (self._sys_executable(), script)
  97
+        cmd = '%s "%s"' % (sys.executable, script)
105 98
         cmd += ''.join([' %s' % arg for arg in args])
106 99
 
107 100
         # Move to the test directory and run
@@ -118,7 +111,7 @@ def run_test(self, script, args, settings_file=None, apps=None):
118 111
         if old_django_settings_module:
119 112
             os.environ['DJANGO_SETTINGS_MODULE'] = old_django_settings_module
120 113
         if old_python_path:
121  
-            os.environ['PYTHONPATH'] = old_python_path
  114
+            os.environ[python_path_var_name] = old_python_path
122 115
         # Move back to the old working directory
123 116
         os.chdir(old_cwd)
124 117
 
@@ -425,7 +418,7 @@ def test_builtin_with_bad_environment(self):
425 418
         self.assertNoOutput(out)
426 419
         self.assertOutput(err, "Could not import settings 'bad_settings'")
427 420
 
428  
-    def test_custom_command(self): 
  421
+    def test_custom_command(self):
429 422
         "alternate: django-admin can't execute user commands unless settings are provided"
430 423
         args = ['noargs_command']
431 424
         out, err = self.run_django_admin(args)
@@ -495,7 +488,7 @@ def test_builtin_with_bad_environment(self):
495 488
         self.assertNoOutput(out)
496 489
         self.assertOutput(err, "Could not import settings 'bad_settings'")
497 490
 
498  
-    def test_custom_command(self): 
  491
+    def test_custom_command(self):
499 492
         "alternate: django-admin can't execute user commands unless settings are provided"
500 493
         args = ['noargs_command']
501 494
         out, err = self.run_django_admin(args)

0 notes on commit fc2c03b

Please sign in to comment.
Something went wrong with that request. Please try again.