1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

Fixed #35429 -- Added argparse choices to --database options.

This commit is contained in:
SaJH
2024-05-08 21:24:44 +09:00
committed by Sarah Boyce
parent 962215db13
commit 4a76ac0e9d
16 changed files with 49 additions and 4 deletions

View File

@@ -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.