summaryrefslogtreecommitdiff
path: root/tests/check_framework
diff options
context:
space:
mode:
authorleondaz <ahmeddark369@gmail.com>2024-09-09 19:15:40 +0300
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2024-10-15 16:39:12 +0200
commit06bf06a911695c5c84f746742f764c040e237ece (patch)
tree3f54dfb3f6889c3f5d6a676e5be8556c0fe303ed /tests/check_framework
parentdc626fbe3ae0225b765df71d08fab02971dc6c6f (diff)
Fixed #35656 -- Added an autodetector attribute to the makemigrations and migrate commands.
Diffstat (limited to 'tests/check_framework')
-rw-r--r--tests/check_framework/custom_commands_app/management/commands/makemigrations.py7
-rw-r--r--tests/check_framework/test_commands.py25
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],
+ )