summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Keith-Magee <russell@keith-magee.com>2006-09-09 14:58:46 +0000
committerRussell Keith-Magee <russell@keith-magee.com>2006-09-09 14:58:46 +0000
commit36added124f73203f0d64a1a5b0f6e4bede35d85 (patch)
tree3c9357dbc7e30995b79474006302c8004387b707
parent5b34781f2808963c003642aa05c3ea25fe1c9fe3 (diff)
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.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3740 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/test/simple.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/django/test/simple.py b/django/test/simple.py
index 043787414e..628fa464d2 100644
--- a/django/test/simple.py
+++ b/django/test/simple.py
@@ -38,10 +38,23 @@ def build_suite(app_module):
except ValueError:
# No doc tests in tests.py
pass
- except ImportError:
- # No tests.py file for application
- pass
-
+ except ImportError, e:
+ # Couldn't import tests.py. Was it due to a missing file, or
+ # due to an import error in a tests.py that actually exists?
+ import os.path
+ from imp import find_module
+ try:
+ mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)])
+ except ImportError:
+ # 'tests' module doesn't exist. Move on.
+ pass
+ else:
+ # The module exists, so there must be an import error in the
+ # test module itself. We don't need the module; close the file
+ # handle returned by find_module.
+ mod[0].close()
+ raise
+
return suite
def run_tests(module_list, verbosity=1, extra_tests=[]):