From 430e796980799feb75901b9918245b6b0bff3f54 Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Fri, 7 Feb 2020 10:37:25 +0100 Subject: [PATCH] Refs #31055 -- Made DiscoverRunner skip running system checks on unused test databases. --- django/test/runner.py | 6 +++--- docs/releases/3.1.txt | 3 +++ docs/topics/testing/advanced.txt | 8 ++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/django/test/runner.py b/django/test/runner.py index ff124064db4..5b634b2ac93 100644 --- a/django/test/runner.py +++ b/django/test/runner.py @@ -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 diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt index fbce69d820d..6bf57e0de33 100644 --- a/docs/releases/3.1.txt +++ b/docs/releases/3.1.txt @@ -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`. + URLs ~~~~ diff --git a/docs/topics/testing/advanced.txt b/docs/topics/testing/advanced.txt index 6ceaedc8fd1..a909c5f3d83 100644 --- a/docs/topics/testing/advanced.txt +++ b/docs/topics/testing/advanced.txt @@ -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 `. + Runs the :doc:`system checks ` on the test ``databases``. + + .. versionadded:: 3.1 + + The ``databases`` parameter was added. .. method:: DiscoverRunner.run_suite(suite, **kwargs)