diff --git a/mopidy/utils/network.py b/mopidy/utils/network.py index 7da31f84..5267afd5 100644 --- a/mopidy/utils/network.py +++ b/mopidy/utils/network.py @@ -269,6 +269,7 @@ class Connection(object): if e.errno in (errno.EWOULDBLOCK, errno.EINTR): return data self.stop(u'Unexpected client error: %s' % e) + return '' def timeout_callback(self): self.stop(u'Client timeout out after %s seconds' % self.timeout) diff --git a/tests/utils/network/connection_test.py b/tests/utils/network/connection_test.py index 6f22aeb3..7241dc5a 100644 --- a/tests/utils/network/connection_test.py +++ b/tests/utils/network/connection_test.py @@ -492,27 +492,20 @@ class ConnectionTest(unittest.TestCase): self.mock.send.assert_called_once_with('data') self.assertEqual('ta', self.mock.send_buffer) - @SkipTest - def test_send_callback_recoverable_error(self): - self.mock.send_lock = Mock() - self.mock.send_lock.acquire.return_value = True - self.mock.send_buffer = 'data' + def test_send_recoverable_error(self): + self.mock.sock = Mock(spec=socket.SocketType) for error in (errno.EWOULDBLOCK, errno.EINTR): self.mock.sock.send.side_effect = socket.error(error, '') - self.assertTrue(network.Connection.send_callback( - self.mock, sentinel.fd, gobject.IO_IN)) + + network.Connection.send(self.mock, 'data') self.assertEqual(0, self.mock.stop.call_count) - @SkipTest - def test_send_callback_unrecoverable_error(self): - self.mock.send_lock = Mock() - self.mock.send_lock.acquire.return_value = True - self.mock.send_buffer = 'data' - + def test_send_unrecoverable_error(self): + self.mock.sock = Mock(spec=socket.SocketType) self.mock.sock.send.side_effect = socket.error - self.assertTrue(network.Connection.send_callback( - self.mock, sentinel.fd, gobject.IO_IN)) + + self.assertEqual('', network.Connection.send(self.mock, 'data')) self.mock.stop.assert_called_once_with(any_unicode) def test_timeout_callback(self):