From 87838f653aab1706bcc53d4e7742c20b0d5c2e4c Mon Sep 17 00:00:00 2001 From: p-goulart Date: Thu, 28 Mar 2024 10:30:37 +0100 Subject: [PATCH] Update shell cmd tests --- tests/test_shell_command.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test_shell_command.py b/tests/test_shell_command.py index cd42429..b1a92a4 100644 --- a/tests/test_shell_command.py +++ b/tests/test_shell_command.py @@ -1,6 +1,6 @@ import pytest -from lib.shell_command import ShellCommand, ShellCommandException +from lib.shell_command import ShellCommand, ShellCommandException, LOGGER class TestShellCommand: @@ -11,10 +11,13 @@ def test_run(self): def test_run_with_input(self): assert ShellCommand("tr 'o' 'a'").run_with_input("foo") == "faa" - def test_run_with_output(self, capsys): + def test_run_with_output(self, caplog): + """Test the run_with_output method: shell command output is redirected to the logger on the debug level.""" + LOGGER.setLevel("DEBUG") ShellCommand("expr 2 + 2").run_with_output() - captured = capsys.readouterr() - assert captured.out == "4\n" + assert caplog.text == ('DEBUG dictionary_tools:shell_command.py:64 Running command: expr 2 + 2\n' + 'DEBUG dictionary_tools:shell_command.py:71 4\n') != '4' + LOGGER.setLevel("FATAL") def test_run_with_not_found_error(self): with pytest.raises(ShellCommandException):