Django

Code

Changeset 3740

Show
Ignore:
Timestamp:
09/09/06 09:58:46 (2 years ago)
Author:
russellm
Message:

Fixes #2669 -- Added check on import of tests.py to differentiate between an absent tests.py, and an existent tests.py with an import error in it.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/test/simple.py

    r3707 r3740  
    3939            # No doc tests in tests.py 
    4040            pass 
    41     except ImportError: 
    42         # No tests.py file for application 
    43         pass             
    44  
     41    except ImportError, e: 
     42        # Couldn't import tests.py. Was it due to a missing file, or 
     43        # due to an import error in a tests.py that actually exists? 
     44        import os.path 
     45        from imp import find_module 
     46        try: 
     47            mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)]) 
     48        except ImportError: 
     49            # 'tests' module doesn't exist. Move on. 
     50            pass 
     51        else: 
     52            # The module exists, so there must be an import error in the  
     53            # test module itself. We don't need the module; close the file 
     54            # handle returned by find_module. 
     55            mod[0].close() 
     56            raise 
     57             
    4558    return suite 
    4659