mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #26981 -- Added DiscoverRunner.get_test_runner_kwargs().
This commit is contained in:
parent
967aa7f6cc
commit
ebed9ee8d5
@ -503,13 +503,17 @@ class DiscoverRunner(object):
|
||||
def get_resultclass(self):
|
||||
return DebugSQLTextTestResult if self.debug_sql else None
|
||||
|
||||
def run_suite(self, suite, **kwargs):
|
||||
resultclass = self.get_resultclass()
|
||||
return self.test_runner(
|
||||
verbosity=self.verbosity,
|
||||
def get_test_runner_kwargs(self):
|
||||
return dict(
|
||||
failfast=self.failfast,
|
||||
resultclass=resultclass,
|
||||
).run(suite)
|
||||
resultclass=self.get_resultclass(),
|
||||
verbosity=self.verbosity,
|
||||
)
|
||||
|
||||
def run_suite(self, suite, **kwargs):
|
||||
kwargs = self.get_test_runner_kwargs()
|
||||
runner = self.test_runner(**kwargs)
|
||||
return runner.run(suite)
|
||||
|
||||
def teardown_databases(self, old_config, **kwargs):
|
||||
"""
|
||||
|
@ -255,7 +255,8 @@ Templates
|
||||
Tests
|
||||
~~~~~
|
||||
|
||||
* ...
|
||||
* Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
|
||||
keyword arguments passed to the test runner.
|
||||
|
||||
URLs
|
||||
~~~~
|
||||
|
@ -568,6 +568,13 @@ Methods
|
||||
|
||||
Returns the result produced by the running the test suite.
|
||||
|
||||
.. method:: DiscoverRunner.get_test_runner_kwargs()
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
Returns the keyword arguments to instantiate the
|
||||
``DiscoverRunner.test_runner`` with.
|
||||
|
||||
.. method:: DiscoverRunner.teardown_databases(old_config, **kwargs)
|
||||
|
||||
Destroys the test databases, restoring pre-test conditions.
|
||||
|
@ -157,6 +157,9 @@ class DiscoverRunnerTest(TestCase):
|
||||
self.assertIn('test_2', suite[8].id(),
|
||||
msg="Methods of unittest cases should be reversed.")
|
||||
|
||||
def test_overridable_get_test_runner_kwargs(self):
|
||||
self.assertIsInstance(DiscoverRunner().get_test_runner_kwargs(), dict)
|
||||
|
||||
def test_overridable_test_suite(self):
|
||||
self.assertEqual(DiscoverRunner().test_suite, TestSuite)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user