diff options
| author | SaJH <wogur981208@gmail.com> | 2024-05-08 21:24:44 +0900 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2024-05-10 11:14:07 +0200 |
| commit | 4a76ac0e9d21c3680cc533ec7f55c0a1919424ba (patch) | |
| tree | bb2991a1ad9a7357d0c46224683f837b44d84176 /tests/admin_scripts | |
| parent | 962215db13506deca67fae5dcba5b5bb4a1029a3 (diff) | |
Fixed #35429 -- Added argparse choices to --database options.
Diffstat (limited to 'tests/admin_scripts')
| -rw-r--r-- | tests/admin_scripts/tests.py | 29 |
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. |
