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:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user