From 4a76ac0e9d21c3680cc533ec7f55c0a1919424ba Mon Sep 17 00:00:00 2001 From: SaJH Date: Wed, 8 May 2024 21:24:44 +0900 Subject: Fixed #35429 -- Added argparse choices to --database options. --- tests/admin_scripts/tests.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/admin_scripts') 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. -- cgit v1.3