diff --git a/django/test/simple.py b/django/test/simple.py
index c9adfd2..a6491a1 100644
a
|
b
|
def get_tests(app_module):
|
49 | 49 | raise |
50 | 50 | return test_module |
51 | 51 | |
52 | | def build_suite(app_module): |
| 52 | def build_suite(app_module, test_loader=unittest.defaultTestLoader): |
53 | 53 | "Create a complete Django test suite for the provided application module" |
54 | 54 | suite = unittest.TestSuite() |
55 | 55 | |
… |
… |
def build_suite(app_module):
|
58 | 58 | if hasattr(app_module, 'suite'): |
59 | 59 | suite.addTest(app_module.suite()) |
60 | 60 | else: |
61 | | suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(app_module)) |
| 61 | suite.addTest(test_loader.loadTestsFromModule(app_module)) |
62 | 62 | try: |
63 | 63 | suite.addTest(doctest.DocTestSuite(app_module, |
64 | 64 | checker=doctestOutputChecker, |
… |
… |
def build_suite(app_module):
|
76 | 76 | if hasattr(test_module, 'suite'): |
77 | 77 | suite.addTest(test_module.suite()) |
78 | 78 | else: |
79 | | suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_module)) |
| 79 | suite.addTest(test_loader.loadTestsFromModule(test_module)) |
80 | 80 | try: |
81 | 81 | suite.addTest(doctest.DocTestSuite(test_module, |
82 | 82 | checker=doctestOutputChecker, |
… |
… |
def build_suite(app_module):
|
86 | 86 | pass |
87 | 87 | return suite |
88 | 88 | |
89 | | def build_test(label): |
| 89 | def build_test(label, test_loader=unittest.defaultTestLoader): |
90 | 90 | """Construct a test case with the specified label. Label should be of the |
91 | 91 | form model.TestClass or model.TestClass.test_method. Returns an |
92 | 92 | instantiated test or test suite corresponding to the label provided. |
… |
… |
def build_test(label):
|
112 | 112 | if issubclass(TestClass, (unittest.TestCase, real_unittest.TestCase)): |
113 | 113 | if len(parts) == 2: # label is app.TestClass |
114 | 114 | try: |
115 | | return unittest.TestLoader().loadTestsFromTestCase(TestClass) |
| 115 | return test_loader.loadTestsFromTestCase(TestClass) |
116 | 116 | except TypeError: |
117 | 117 | raise ValueError("Test label '%s' does not refer to a test class" % label) |
118 | 118 | else: # label is app.TestClass.test_method |
… |
… |
def dependency_ordered(test_databases, dependencies):
|
220 | 220 | test_databases = deferred |
221 | 221 | return ordered_test_databases |
222 | 222 | |
| 223 | |
| 224 | |
223 | 225 | class DjangoTestSuiteRunner(object): |
| 226 | suite_class = unittest.TestSuite |
| 227 | runner_class = unittest.TextTestRunner |
| 228 | test_loader = unittest.defaultTestLoader |
| 229 | |
224 | 230 | def __init__(self, verbosity=1, interactive=True, failfast=True, **kwargs): |
225 | 231 | self.verbosity = verbosity |
226 | 232 | self.interactive = interactive |
… |
… |
class DjangoTestSuiteRunner(object):
|
232 | 238 | unittest.installHandler() |
233 | 239 | |
234 | 240 | def build_suite(self, test_labels, extra_tests=None, **kwargs): |
235 | | suite = unittest.TestSuite() |
| 241 | suite = self.suite_class() |
236 | 242 | |
237 | 243 | if test_labels: |
238 | 244 | for label in test_labels: |
239 | 245 | if '.' in label: |
240 | | suite.addTest(build_test(label)) |
| 246 | suite.addTest(build_test(label, self.test_loader)) |
241 | 247 | else: |
242 | 248 | app = get_app(label) |
243 | | suite.addTest(build_suite(app)) |
| 249 | suite.addTest(build_suite(app, self.test_loader)) |
244 | 250 | else: |
245 | 251 | for app in get_apps(): |
246 | | suite.addTest(build_suite(app)) |
| 252 | suite.addTest(build_suite(app, self.test_loader)) |
247 | 253 | |
248 | 254 | if extra_tests: |
249 | 255 | for test in extra_tests: |
… |
… |
class DjangoTestSuiteRunner(object):
|
308 | 314 | return old_names, mirrors |
309 | 315 | |
310 | 316 | def run_suite(self, suite, **kwargs): |
311 | | return unittest.TextTestRunner(verbosity=self.verbosity, failfast=self.failfast).run(suite) |
| 317 | return self.runner_class(verbosity=self.verbosity, failfast=self.failfast).run(suite) |
312 | 318 | |
313 | 319 | def teardown_databases(self, old_config, **kwargs): |
314 | 320 | from django.db import connections |