Django

Code

Changeset 8238

Show
Ignore:
Timestamp:
08/08/08 13:48:18 (4 months ago)
Author:
jacob
Message:

Fixed #8047: property detect an external database backend and set sys.path accordingly. Patch from Leo Soto.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/tests/regressiontests/admin_scripts/tests.py

    r8228 r8238  
    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 
     
    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