summaryrefslogtreecommitdiff
path: root/tests/user_commands/tests.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2021-10-22 16:38:14 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-10-25 10:09:06 +0200
commitc9ebe4ca4e3f5d5d76bfbdae489e3f44e32416e5 (patch)
tree108af2ab73ab082133dd937c937198e038fc5f3e /tests/user_commands/tests.py
parentac815f6ea83a66122ee434f773f8c923f4cd3125 (diff)
[4.0.x] Fixed #33205 -- Made call_command() raise TypeError when dest with multiple arguments is passed.
Backport of c1e4111c74ee9d9f48cbee5a5b7c40289203c93d from main
Diffstat (limited to 'tests/user_commands/tests.py')
-rw-r--r--tests/user_commands/tests.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 60cfe86b3d..a727e56efb 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -275,6 +275,41 @@ class CommandTests(SimpleTestCase):
)
self.assertIn(expected_output, out.getvalue())
+ def test_mutually_exclusive_group_required_with_same_dest_options(self):
+ tests = [
+ {'until': '2'},
+ {'for': '1', 'until': '2'},
+ ]
+ msg = (
+ "Cannot pass the dest 'until' that matches multiple arguments via "
+ "**options."
+ )
+ for options in tests:
+ with self.subTest(options=options):
+ with self.assertRaisesMessage(TypeError, msg):
+ management.call_command(
+ 'mutually_exclusive_required_with_same_dest',
+ **options,
+ )
+
+ def test_mutually_exclusive_group_required_with_same_dest_args(self):
+ tests = [
+ ('--until=1',),
+ ('--until', 1),
+ ('--for=1',),
+ ('--for', 1),
+ ]
+ for args in tests:
+ out = StringIO()
+ with self.subTest(options=args):
+ management.call_command(
+ 'mutually_exclusive_required_with_same_dest',
+ *args,
+ stdout=out,
+ )
+ output = out.getvalue()
+ self.assertIn('until=1', output)
+
def test_required_list_option(self):
tests = [
(('--foo-list', [1, 2]), {}),