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):
|
def get_resultclass(self):
|
||||||
return DebugSQLTextTestResult if self.debug_sql else None
|
return DebugSQLTextTestResult if self.debug_sql else None
|
||||||
|
|
||||||
def run_suite(self, suite, **kwargs):
|
def get_test_runner_kwargs(self):
|
||||||
resultclass = self.get_resultclass()
|
return dict(
|
||||||
return self.test_runner(
|
|
||||||
verbosity=self.verbosity,
|
|
||||||
failfast=self.failfast,
|
failfast=self.failfast,
|
||||||
resultclass=resultclass,
|
resultclass=self.get_resultclass(),
|
||||||
).run(suite)
|
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):
|
def teardown_databases(self, old_config, **kwargs):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -255,7 +255,8 @@ Templates
|
||||||
Tests
|
Tests
|
||||||
~~~~~
|
~~~~~
|
||||||
|
|
||||||
* ...
|
* Added :meth:`.DiscoverRunner.get_test_runner_kwargs` to allow customizing the
|
||||||
|
keyword arguments passed to the test runner.
|
||||||
|
|
||||||
URLs
|
URLs
|
||||||
~~~~
|
~~~~
|
||||||
|
|
|
@ -568,6 +568,13 @@ Methods
|
||||||
|
|
||||||
Returns the result produced by the running the test suite.
|
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)
|
.. method:: DiscoverRunner.teardown_databases(old_config, **kwargs)
|
||||||
|
|
||||||
Destroys the test databases, restoring pre-test conditions.
|
Destroys the test databases, restoring pre-test conditions.
|
||||||
|
|
|
@ -157,6 +157,9 @@ class DiscoverRunnerTest(TestCase):
|
||||||
self.assertIn('test_2', suite[8].id(),
|
self.assertIn('test_2', suite[8].id(),
|
||||||
msg="Methods of unittest cases should be reversed.")
|
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):
|
def test_overridable_test_suite(self):
|
||||||
self.assertEqual(DiscoverRunner().test_suite, TestSuite)
|
self.assertEqual(DiscoverRunner().test_suite, TestSuite)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue