mirror of
https://github.com/django/django.git
synced 2025-11-19 11:15:44 +00:00
Refs #31055 -- Augmented regression tests for database system checks.
We might want to change this in the future but it should be further discussed first.
This commit is contained in:
parent
abfa4619fb
commit
1b539ef27e
2 changed files with 34 additions and 3 deletions
|
|
@ -1,11 +1,11 @@
|
|||
import multiprocessing
|
||||
import sys
|
||||
from io import StringIO
|
||||
from unittest import skipIf
|
||||
from unittest import mock, skipIf
|
||||
|
||||
from django.apps import apps
|
||||
from django.core import checks
|
||||
from django.core.checks import Error, Warning
|
||||
from django.core.checks import Error, Tags, Warning
|
||||
from django.core.checks.messages import CheckMessage
|
||||
from django.core.checks.registry import CheckRegistry
|
||||
from django.core.management import call_command
|
||||
|
|
@ -268,6 +268,18 @@ class CheckCommandTests(SimpleTestCase):
|
|||
with self.assertRaises(CommandError):
|
||||
call_command("check", fail_level="WARNING")
|
||||
|
||||
def test_database_system_checks(self):
|
||||
database_check = mock.Mock(return_value=[], tags=[Tags.database])
|
||||
|
||||
with override_system_checks([database_check]):
|
||||
call_command("check")
|
||||
database_check.assert_called_once_with(app_configs=None, databases=None)
|
||||
database_check.reset_mock()
|
||||
call_command("check", databases=["default"])
|
||||
database_check.assert_called_once_with(
|
||||
app_configs=None, databases=["default"]
|
||||
)
|
||||
|
||||
|
||||
def custom_error_system_check(app_configs, **kwargs):
|
||||
return [Error("Error", id="myerrorcheck.E001")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue