Refs #32047 -- Added test for using call_command() with constant required options.

This commit is contained in:
Hasan Ramezani 2020-10-06 00:13:09 +02:00 committed by Mariusz Felisiak
parent 0ef04fdd7a
commit efe74fff25
2 changed files with 46 additions and 0 deletions

View file

@ -275,6 +275,32 @@ class CommandTests(SimpleTestCase):
)
self.assertIn(expected_output, out.getvalue())
def test_required_const_options(self):
args = {
'append_const': [42],
'const': 31,
'count': 1,
'flag_false': False,
'flag_true': True,
}
expected_output = '\n'.join(
'%s=%s' % (arg, value) for arg, value in args.items()
)
out = StringIO()
management.call_command(
'required_constant_option',
'--append_const',
'--const',
'--count',
'--flag_false',
'--flag_true',
stdout=out,
)
self.assertIn(expected_output, out.getvalue())
out.truncate(0)
management.call_command('required_constant_option', **{**args, 'stdout': out})
self.assertIn(expected_output, out.getvalue())
def test_subparser(self):
out = StringIO()
management.call_command('subparser', 'foo', 12, stdout=out)