summaryrefslogtreecommitdiff
path: root/tests/user_commands/tests.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2019-09-05 23:45:56 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2019-09-06 10:55:24 +0200
commit6c379f1a1897a0e0b95531ea7d9806b17b22ff89 (patch)
tree5c2edc05a83f3a67b4de807099dacca7bf2c9f03 /tests/user_commands/tests.py
parent350123f38c2b6217c38d70bfbd924a9ba3df1289 (diff)
downloaddjango-6c379f1a1897a0e0b95531ea7d9806b17b22ff89.tar.gz
Fixed #30763 -- Fixed management commands when using required mutually exclusive groups.
Diffstat (limited to 'tests/user_commands/tests.py')
-rw-r--r--tests/user_commands/tests.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index a53c781ac6..4e730472f5 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -214,6 +214,16 @@ class CommandTests(SimpleTestCase):
management.call_command('common_args', stdout=out)
self.assertIn('Detected that --version already exists', out.getvalue())
+ def test_mutually_exclusive_group_required_options(self):
+ out = StringIO()
+ management.call_command('mutually_exclusive_required', foo_id=1, stdout=out)
+ self.assertIn('foo_id', out.getvalue())
+ 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 is required'
+ with self.assertRaisesMessage(CommandError, msg):
+ management.call_command('mutually_exclusive_required', stdout=out)
+
def test_subparser(self):
out = StringIO()
management.call_command('subparser', 'foo', 12, stdout=out)