mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Fixed #32153 -- Fixed management commands when using required list options.
Thanks Mark Gajdosik for the report and initial patch.
This commit is contained in:
parent
966b5b49b6
commit
f06beea929
4 changed files with 47 additions and 10 deletions
|
@ -244,8 +244,9 @@ class CommandTests(SimpleTestCase):
|
|||
management.call_command('mutually_exclusive_required', foo_name='foo', stdout=out)
|
||||
self.assertIn('foo_name', out.getvalue())
|
||||
msg = (
|
||||
'Error: one of the arguments --foo-id --foo-name --append_const '
|
||||
'--const --count --flag_false --flag_true is required'
|
||||
'Error: one of the arguments --foo-id --foo-name --foo-list '
|
||||
'--append_const --const --count --flag_false --flag_true is '
|
||||
'required'
|
||||
)
|
||||
with self.assertRaisesMessage(CommandError, msg):
|
||||
management.call_command('mutually_exclusive_required', stdout=out)
|
||||
|
@ -275,6 +276,22 @@ class CommandTests(SimpleTestCase):
|
|||
)
|
||||
self.assertIn(expected_output, out.getvalue())
|
||||
|
||||
def test_required_list_option(self):
|
||||
tests = [
|
||||
(('--foo-list', [1, 2]), {}),
|
||||
((), {'foo_list': [1, 2]}),
|
||||
]
|
||||
for command in ['mutually_exclusive_required', 'required_list_option']:
|
||||
for args, kwargs in tests:
|
||||
with self.subTest(command=command, args=args, kwargs=kwargs):
|
||||
out = StringIO()
|
||||
management.call_command(
|
||||
command,
|
||||
*args,
|
||||
**{**kwargs, 'stdout': out},
|
||||
)
|
||||
self.assertIn('foo_list=[1, 2]', out.getvalue())
|
||||
|
||||
def test_required_const_options(self):
|
||||
args = {
|
||||
'append_const': [42],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue