summaryrefslogtreecommitdiff
path: root/tests/user_commands/tests.py
diff options
context:
space:
mode:
authorHasan Ramezani <hasan.r67@gmail.com>2018-04-21 23:04:00 +0430
committerTim Graham <timograham@gmail.com>2018-04-21 17:33:17 -0400
commitdd68b51e1da54267bde4799fa0d9fbd4290eb8b5 (patch)
tree31204a0acaf1d4a94dfd683111a88d0f5b0b7572 /tests/user_commands/tests.py
parent21420096c4db78ccb8f549a29d662cff870d363c (diff)
Fixed #29295 -- Fixed management command crash when using subparsers.
Thanks Tim Graham for the fix.
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 ae05bcfe25..61e649c75a 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -206,6 +206,16 @@ class CommandTests(SimpleTestCase):
self.assertIn('need_me', out.getvalue())
self.assertIn('needme2', out.getvalue())
+ def test_subparser(self):
+ out = StringIO()
+ management.call_command('subparser', 'foo', 12, stdout=out)
+ self.assertIn('bar', out.getvalue())
+
+ def test_subparser_invalid_option(self):
+ msg = "Error: invalid choice: 'test' (choose from 'foo')"
+ with self.assertRaisesMessage(CommandError, msg):
+ management.call_command('subparser', 'test', 12)
+
class CommandRunTests(AdminScriptTestCase):
"""