def test_loopbackcomm_read_raw_2char_terminator(): mock_stdin = mock.MagicMock() mock_stdin.read.side_effect = [b"a", b"b", b"c", b"\r", b"\n"] comm = LoopbackCommunicator(stdin=mock_stdin) comm._terminator = "\r\n" assert comm.read_raw() == b"abc" mock_stdin.read.assert_has_calls([mock.call(1)]*5) assert mock_stdin.read.call_count == 5
def test_loopbackcomm_read_raw_terminator_is_empty_string(): mock_stdin = mock.MagicMock() mock_stdin.read.side_effect = [b"abc"] comm = LoopbackCommunicator(stdin=mock_stdin) comm._terminator = "" assert comm.read_raw() == b"abc" mock_stdin.read.assert_has_calls([mock.call(-1)]) assert mock_stdin.read.call_count == 1