summaryrefslogtreecommitdiff
path: root/tests/test_completion.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-22 00:08:27 -0500
committerTodd Leonhardt <todd.leonhardt@gmail.com>2018-01-22 00:08:27 -0500
commitf28c10a50535f753419bd2120ac6cb0bea9f56e2 (patch)
tree102b200c4a3dff1adad4bf326ea3f6de9cd56baf /tests/test_completion.py
parentc9f7c012bda012b4df7a8c5e853bd5d3e6d99b1b (diff)
downloadcmd2-git-f28c10a50535f753419bd2120ac6cb0bea9f56e2.tar.gz
help command temporarily redirects sys.stdout and sys.stderr to self.stdout for argparse commands
In order to make "help" behave more consistently for decorated and undecorated commands, argparse output is temporarily redirected to self.stdout. So doing "help history" is similar to "help load". However, when using the "-h" with argparse commands without using the "help" command, the output from argparse isn't redirected to self.stdout. Fixing this would be rather difficult and would essentially involve creating a pyparsing rule to detect it at the parser level.
Diffstat (limited to 'tests/test_completion.py')
-rw-r--r--tests/test_completion.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_completion.py b/tests/test_completion.py
index 05774df9..70f77d0a 100644
--- a/tests/test_completion.py
+++ b/tests/test_completion.py
@@ -80,9 +80,9 @@ def test_complete_command_invalid_state(cmd2_app):
with mock.patch.object(readline, 'get_line_buffer', get_line):
with mock.patch.object(readline, 'get_begidx', get_begidx):
with mock.patch.object(readline, 'get_endidx', get_endidx):
- with pytest.raises(AttributeError):
- # Run the readline tab-completion function with readline mocks in place and cause an exception
- completion = cmd2_app.complete(text, state)
+ # Run the readline tab-completion function with readline mocks in place get None
+ completion = cmd2_app.complete(text, state)
+ assert completion is None
def test_complete_empty_arg(cmd2_app):
text = ''