Ticket #8047: 8047_admin_scripts_tests_on_jython.5.diff

File 8047_admin_scripts_tests_on_jython.5.diff, 2.4 KB (added by Leo Soto M., 16 years ago)

I screwed up the patch the last time. Now it is ok

  • tests/regressiontests/admin_scripts/tests.py

    diff -r 6459429f18fb tests/regressiontests/admin_scripts/tests.py
    a b  
    4242        test_dir = os.path.dirname(os.path.dirname(__file__))
    4343        full_name = os.path.join(test_dir, filename)
    4444        os.remove(full_name)
    45        
     45
    4646        # Also try to remove the compiled file; if it exists, it could
    4747        # mess up later tests that depend upon the .py file not existing
    4848        try:
     
    5454                os.remove(full_name + 'c')
    5555        except OSError:
    5656            pass
    57        
     57
    5858    def _sys_executable(self):
    5959        """
    6060        Returns the command line needed to run a python interpreter, including
     
    6767        else:
    6868            return sys.executable
    6969
     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)
    7081    def run_test(self, script, args, settings_file=None, apps=None):
    7182        test_dir = os.path.dirname(os.path.dirname(__file__))
    7283        project_dir = os.path.dirname(test_dir)
    7384        base_dir = os.path.dirname(project_dir)
     85        ext_backend_base_dir = self._ext_backend_path()
    7486
    7587        # Remember the old environment
    7688        old_django_settings_module = os.environ.get('DJANGO_SETTINGS_MODULE', None)
     
    8294            os.environ['DJANGO_SETTINGS_MODULE'] = settings_file
    8395        elif 'DJANGO_SETTINGS_MODULE' in os.environ:
    8496            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
    90102
    91103        # Build the command line
    92104        cmd = '%s "%s"' % (self._sys_executable(), script)
Back to Top