Refs #31055 -- Made DiscoverRunner skip running system checks on unused test databases.

This commit is contained in:
Simon Charette 2020-02-07 10:37:25 +01:00 committed by Mariusz Felisiak
parent 0b83c8cc4d
commit 430e796980
3 changed files with 12 additions and 5 deletions

View File

@ -630,10 +630,10 @@ class DiscoverRunner:
'buffer': self.buffer,
}
def run_checks(self):
def run_checks(self, databases):
# Checks are run after database creation since some checks require
# database access.
call_command('check', verbosity=self.verbosity)
call_command('check', verbosity=self.verbosity, databases=databases)
def run_suite(self, suite, **kwargs):
kwargs = self.get_test_runner_kwargs()
@ -695,7 +695,7 @@ class DiscoverRunner:
old_config = self.setup_databases(aliases=databases)
run_failed = False
try:
self.run_checks()
self.run_checks(databases)
result = self.run_suite(suite)
except Exception:
run_failed = True

View File

@ -332,6 +332,9 @@ Tests
* Django test runner now supports a :option:`test --buffer` option to discard
output for passing tests.
* :class:`~django.test.runner.DiscoverRunner` now skips running the system
checks on databases not :ref:`referenced by tests<testing-multi-db>`.
URLs
~~~~

View File

@ -637,9 +637,13 @@ Methods
Creates the test databases by calling
:func:`~django.test.utils.setup_databases`.
.. method:: DiscoverRunner.run_checks()
.. method:: DiscoverRunner.run_checks(databases)
Runs the :doc:`system checks </topics/checks>`.
Runs the :doc:`system checks </topics/checks>` on the test ``databases``.
.. versionadded:: 3.1
The ``databases`` parameter was added.
.. method:: DiscoverRunner.run_suite(suite, **kwargs)