diff --git a/webserver/lib/django-1.3/django/test/simple.py b/webserver/lib/django-1.3/django/test/simple.py
index 1b26ebb..ac05604 100644
a
|
b
|
def get_tests(app_module):
|
38 | 38 | except ImportError, e: |
39 | 39 | # Couldn't import tests.py. Was it due to a missing file, or |
40 | 40 | # due to an import error in a tests.py that actually exists? |
41 | | import os.path |
42 | | from imp import find_module |
43 | | try: |
44 | | mod = find_module(TEST_MODULE, [os.path.dirname(app_module.__file__)]) |
45 | | except ImportError: |
46 | | # 'tests' module doesn't exist. Move on. |
| 41 | # app_module either points to a models.py file, or models/__init__.py |
| 42 | # Tests are therefore either in same directory, or one level up |
| 43 | from django.utils.module_loading import module_has_submodule |
| 44 | if app_module.__name__.split('.')[-1] == 'models': |
| 45 | root_name = '.'.join(app_module.__name__.split('.')[:-1]) |
| 46 | __import__(root_name) |
| 47 | app_root = sys.modules[root_name] |
| 48 | else: |
| 49 | app_root = app_module |
| 50 | |
| 51 | if not module_has_submodule(app_root, 'tests'): |
47 | 52 | test_module = None |
| 53 | |
48 | 54 | else: |
49 | 55 | # The module exists, so there must be an import error in the |
50 | | # test module itself. We don't need the module; so if the |
51 | | # module was a single file module (i.e., tests.py), close the file |
52 | | # handle returned by find_module. Otherwise, the test module |
53 | | # is a directory, and there is nothing to close. |
54 | | if mod[0]: |
55 | | mod[0].close() |
| 56 | # test module itself. |
56 | 57 | raise |
57 | 58 | return test_module |
58 | 59 | |
diff --git a/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/__init__.py b/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/__init__.py
new file mode 100644
index 0000000..a455e83
-
|
+
|
|
| 1 | # Example of directory model & test layout that causes issue #12658 |
| 2 | # The tests raise an ImportError so this test is marked as invalid |
diff --git a/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/models/__init__.py b/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/models/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/tests/__init__.py b/webserver/lib/django-1.3/tests/regressiontests/invalid_tests_importerror/tests/__init__.py
new file mode 100644
index 0000000..1054d18
-
|
+
|
|
| 1 | # Tests that raise ImportError should not fail silently. |
| 2 | # This is a support fixture for test_get_tests |
| 3 | raise ImportError |
diff --git a/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/__init__.py b/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/models.py b/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/models.py
new file mode 100644
index 0000000..e69de29
diff --git a/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/tests.py b/webserver/lib/django-1.3/tests/regressiontests/test_get_tests/tests.py
new file mode 100644
index 0000000..0542fd3
-
|
+
|
|
| 1 | import sys |
| 2 | |
| 3 | from django.core.exceptions import ImproperlyConfigured |
| 4 | from django.test import simple |
| 5 | from django.utils import unittest |
| 6 | from django.test.simple import get_tests |
| 7 | from django.db.models.loading import get_app |
| 8 | |
| 9 | TEST_APP_OK = 'test_model_and_tests_package.models' |
| 10 | TEST_APP_ERROR = 'invalid_tests_importerror.models' |
| 11 | |
| 12 | def load_test_app(name): |
| 13 | """Load a non-registered app in a sibling directory to this test""" |
| 14 | path = __package__.split('.')[:-1] |
| 15 | name = '.'.join(path+[name]) |
| 16 | __import__(name) |
| 17 | return sys.modules[name] |
| 18 | |
| 19 | class GetTestTests(unittest.TestCase): |
| 20 | def test_get_tests(self): |
| 21 | "Check we can find tests in directory" |
| 22 | module = load_test_app(TEST_APP_OK) |
| 23 | tests = get_tests(module) |
| 24 | self.assert_(isinstance(tests, type(module))) |
| 25 | |
| 26 | def test_import_error(self): |
| 27 | "Test for #12658 - tests with importerrors fail silently" |
| 28 | module = load_test_app(TEST_APP_ERROR) |
| 29 | self.assertRaises(ImportError, get_tests, module) |
| 30 | |
diff --git a/webserver/lib/django-1.3/tests/regressiontests/test_model_and_tests_package/__init__.py b/webserver/lib/django-1.3/tests/regressiontests/test_model_and_tests_package/__init__.py
new file mode 100644
index 0000000..3ad4f58
-
|
+
|
|
| 1 | # Example of directory model & test layout that causes issue #12658 |