コード例 #1
0
 def test_strip_new_lines(self):
     conn = Mock()
     result = Mock()
     result.receive.side_effect = [{'error': 'an error message\n\n'}, EOFError]
     log.reporting(conn, result)
     message = conn.logger.error.call_args[0][0]
     assert message == 'an error message'
コード例 #2
0
 def test_timeout_error(self):
     conn = Mock()
     result = Mock()
     result.receive.side_effect = TimeoutError
     log.reporting(conn, result)
     message = conn.logger.warning.call_args[0][0]
     assert 'No data was received after ' in message
コード例 #3
0
 def test_write_info_statements(self):
     conn = Mock()
     result = Mock()
     result.receive.side_effect = [{'error': 'an error message'}, EOFError]
     log.reporting(conn, result)
     assert conn.logger.debug.called is False
     assert conn.logger.error.called is True
コード例 #4
0
 def test_reporting_when_channel_is_empty(self):
     conn = Mock()
     result = Mock()
     result.receive.side_effect = EOFError
     log.reporting(conn, result)
コード例 #5
0
 def test_raises_other_errors(self):
     conn = Mock()
     result = Mock()
     result.receive.side_effect = OSError
     with raises(OSError):
         log.reporting(conn, result)