Skip to content

Commit

Permalink
Fix test_on_core_read_ready_os_error_suppressed test on multiple run
Browse files Browse the repository at this point in the history
  • Loading branch information
xoriole committed Jun 27, 2023
1 parent 178f583 commit b9b038b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/tribler/gui/tests/test_core_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ def test_on_core_stderr_read_ready(mocked_print, core_manager):
mocked_print.assert_called_with('core stderr', file=sys.stderr)


@patch('builtins.print', MagicMock(side_effect=OSError()))
def test_on_core_read_ready_os_error_suppressed(core_manager):
# OSError exceptions when writing to stdout and stderr are suppressed
core_manager.app_manager.quitting_app = False
core_manager.on_core_stdout_read_ready()
core_manager.on_core_stderr_read_ready()
assert print.call_count == 2

# if app is quitting, core_manager does not write to stdout/stderr at all, and so the call counter does not grow
core_manager.app_manager.quitting_app = True
core_manager.on_core_stdout_read_ready()
core_manager.on_core_stderr_read_ready()
assert print.call_count == 2
with patch('builtins.print', MagicMock(side_effect=OSError())) as mock_print:
# OSError exceptions when writing to stdout and stderr are suppressed
core_manager.app_manager.quitting_app = False
core_manager.on_core_stdout_read_ready()
core_manager.on_core_stderr_read_ready()
assert mock_print.call_count == 2

# if app is quitting, core_manager does not write to stdout/stderr at all, and so the call counter does not grow
core_manager.app_manager.quitting_app = True
core_manager.on_core_stdout_read_ready()
core_manager.on_core_stderr_read_ready()
assert mock_print.call_count == 2


def test_decode_raw_core_output(core_manager):
Expand Down

0 comments on commit b9b038b

Please sign in to comment.