diff options
Diffstat (limited to 'tests/check_framework')
| -rw-r--r-- | tests/check_framework/custom_commands_app/management/commands/makemigrations.py | 7 | ||||
| -rw-r--r-- | tests/check_framework/test_commands.py | 25 |
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/check_framework/custom_commands_app/management/commands/makemigrations.py b/tests/check_framework/custom_commands_app/management/commands/makemigrations.py new file mode 100644 index 0000000000..a6494cba4c --- /dev/null +++ b/tests/check_framework/custom_commands_app/management/commands/makemigrations.py @@ -0,0 +1,7 @@ +from django.core.management.commands.makemigrations import ( + Command as MakeMigrationsCommand, +) + + +class Command(MakeMigrationsCommand): + autodetector = int diff --git a/tests/check_framework/test_commands.py b/tests/check_framework/test_commands.py new file mode 100644 index 0000000000..a51db77402 --- /dev/null +++ b/tests/check_framework/test_commands.py @@ -0,0 +1,25 @@ +from django.core import checks +from django.core.checks import Error +from django.test import SimpleTestCase +from django.test.utils import isolate_apps, override_settings, override_system_checks + + +@isolate_apps("check_framework.custom_commands_app", attr_name="apps") +@override_settings(INSTALLED_APPS=["check_framework.custom_commands_app"]) +@override_system_checks([checks.commands.migrate_and_makemigrations_autodetector]) +class CommandCheckTests(SimpleTestCase): + def test_migrate_and_makemigrations_autodetector_different(self): + expected_error = Error( + "The migrate and makemigrations commands must have the same " + "autodetector.", + hint=( + "makemigrations.Command.autodetector is int, but " + "migrate.Command.autodetector is MigrationAutodetector." + ), + id="commands.E001", + ) + + self.assertEqual( + checks.run_checks(app_configs=self.apps.get_app_configs()), + [expected_error], + ) |
