diff options
-rw-r--r-- | cmd2/cmd2.py | 5 | ||||
-rw-r--r-- | tests/test_cmd2.py | 29 |
2 files changed, 20 insertions, 14 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py index e32b3180..37fed5a6 100644 --- a/cmd2/cmd2.py +++ b/cmd2/cmd2.py @@ -2054,7 +2054,8 @@ class Cmd(cmd.Cmd): return self.do_shell(statement.command_and_args) else: - self.poutput('*** {} is not a recognized command, alias, or macro\n'.format(statement.command)) + self.perror('*** {} is not a recognized command, alias, or macro'.format(statement.command), + err_color=Fore.RESET, traceback_war=False) def pseudo_raw_input(self, prompt: str) -> str: """Began life as a copy of cmd's cmdloop; like raw_input but @@ -3706,7 +3707,7 @@ class Cmd(cmd.Cmd): :param message_to_print: the message reporting that the command is disabled :param kwargs: not used """ - self.poutput(message_to_print) + self.perror(message_to_print, err_color=Fore.RESET, traceback_war=False) def cmdloop(self, intro: Optional[str] = None) -> None: """This is an outer wrapper around _cmdloop() which deals with extra features provided by cmd2. 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 |