Debian Codegraph @

tests/check_framework/test_commands.py

raw
1 from django.core import checks
2 from django.core.checks import Error
3 from django.test import SimpleTestCase
4 from django.test.utils import isolate_apps, override_settings, override_system_checks
5
6
7 @isolate_apps("check_framework.custom_commands_app", attr_name="apps")
8 @override_settings(INSTALLED_APPS=["check_framework.custom_commands_app"])
9 @override_system_checks([checks.commands.migrate_and_makemigrations_autodetector])
10 class CommandCheckTests(SimpleTestCase):
11 def test_migrate_and_makemigrations_autodetector_different(self):
12 expected_error = Error(
13 "The migrate and makemigrations commands must have the same "
14 "autodetector.",
15 hint=(
16 "makemigrations.Command.autodetector is int, but "
17 "migrate.Command.autodetector is MigrationAutodetector."
18 ),
19 id="commands.E001",
20 )
21
22 self.assertEqual(
23 checks.run_checks(app_configs=self.apps.get_app_configs()),
24 [expected_error],
25 )