summaryrefslogtreecommitdiff
path: root/tests/admin_scripts/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/admin_scripts/tests.py')
-rw-r--r--tests/admin_scripts/tests.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index 688aaa0a2f..c2bb9f9e5d 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -2301,6 +2301,35 @@ class Discovery(SimpleTestCase):
self.assertEqual(out.getvalue().strip(), "simple_app")
+class CommandDBOptionChoiceTests(SimpleTestCase):
+ def test_invalid_choice_db_option(self):
+ expected_error = (
+ "Error: argument --database: invalid choice: "
+ "'deflaut' (choose from 'default', 'other')"
+ )
+ args = [
+ "changepassword",
+ "createsuperuser",
+ "remove_stale_contenttypes",
+ "check",
+ "createcachetable",
+ "dbshell",
+ "flush",
+ "dumpdata",
+ "inspectdb",
+ "loaddata",
+ "showmigrations",
+ "sqlflush",
+ "sqlmigrate",
+ "sqlsequencereset",
+ "migrate",
+ ]
+
+ for arg in args:
+ with self.assertRaisesMessage(CommandError, expected_error):
+ call_command(arg, "--database", "deflaut", verbosity=0)
+
+
class ArgumentOrder(AdminScriptTestCase):
"""Tests for 2-stage argument parsing scheme.