summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-13 17:54:47 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2019-03-13 17:54:47 -0400
commit258ad43a8fedd37d4aca5c3694e20a052b88ffbe (patch)
tree1072dca2cacb44239799869d8917fcca1b44f16a /tests
parent677e8bb845ecee0bc58035095fc599ffb074c00f (diff)
downloadcmd2-git-258ad43a8fedd37d4aca5c3694e20a052b88ffbe.tar.gz
Writing to stderr in default() and _report_disabled_command_usage() to make it easy to detect an error in pyscript
Diffstat (limited to 'tests')
-rw-r--r--tests/test_cmd2.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/tests/test_cmd2.py b/tests/test_cmd2.py
index b3942203..4743744a 100644
--- a/tests/test_cmd2.py
+++ b/tests/test_cmd2.py
@@ -292,9 +292,10 @@ def test_pyscript_requires_an_argument(base_app, capsys):
assert "the following arguments are required: script_path" in err
-def test_base_error(base_app):
- out = run_cmd(base_app, 'meow')
- assert "is not a recognized command" in out[0]
+def test_base_error(base_app, capsys):
+ run_cmd(base_app, 'meow')
+ out, err = capsys.readouterr()
+ assert "is not a recognized command" in err
def test_base_load(base_app, request):
@@ -2199,23 +2200,27 @@ def disable_commands_app():
return app
-def test_disable_and_enable_category(disable_commands_app):
+def test_disable_and_enable_category(disable_commands_app, capsys):
# Disable the category
message_to_print = 'These commands are currently disabled'
disable_commands_app.disable_category(disable_commands_app.category_name, message_to_print)
# Make sure all the commands and help on those commands displays the message
- out = run_cmd(disable_commands_app, 'has_help_func')
- assert out == [message_to_print]
+ run_cmd(disable_commands_app, 'has_help_func')
+ out, err = capsys.readouterr()
+ assert err.startswith(message_to_print)
- out = run_cmd(disable_commands_app, 'help has_help_func')
- assert out == [message_to_print]
+ run_cmd(disable_commands_app, 'help has_help_func')
+ out, err = capsys.readouterr()
+ assert err.startswith(message_to_print)
- out = run_cmd(disable_commands_app, 'has_no_help_func')
- assert out == [message_to_print]
+ run_cmd(disable_commands_app, 'has_no_help_func')
+ out, err = capsys.readouterr()
+ assert err.startswith(message_to_print)
- out = run_cmd(disable_commands_app, 'help has_no_help_func')
- assert out == [message_to_print]
+ run_cmd(disable_commands_app, 'help has_no_help_func')
+ out, err = capsys.readouterr()
+ assert err.startswith(message_to_print)
visible_commands = disable_commands_app.get_visible_commands()
assert 'has_help_func' not in visible_commands