Browse Source

Fix: SimpleClient.call does not raise TimeoutError on timeout (#1501)

pull/1505/head
James Thistlewood 2 weeks ago
committed by GitHub
parent
commit
a59c6f5200
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      src/socketio/async_simple_client.py
  2. 2
      src/socketio/simple_client.py
  3. 11
      tests/async/test_simple_client.py
  4. 10
      tests/common/test_simple_client.py

2
src/socketio/async_simple_client.py

@ -163,6 +163,8 @@ class AsyncSimpleClient:
return await self.client.call(event, data,
namespace=self.namespace,
timeout=timeout)
except TimeoutError:
raise
except SocketIOError:
pass

2
src/socketio/simple_client.py

@ -155,6 +155,8 @@ class SimpleClient:
try:
return self.client.call(event, data, namespace=self.namespace,
timeout=timeout)
except TimeoutError:
raise
except SocketIOError:
pass

11
tests/async/test_simple_client.py

@ -142,6 +142,17 @@ class TestAsyncAsyncSimpleClient:
client.client.call.assert_awaited_with('foo', 'bar', namespace='/',
timeout=60)
async def test_call_timeout(self):
client = AsyncSimpleClient()
client.connected_event.set()
client.connected = True
client.client = mock.MagicMock()
client.client.call = mock.AsyncMock()
client.client.call.side_effect = TimeoutError()
with pytest.raises(TimeoutError):
await client.call('foo', 'bar')
async def test_receive_with_input_buffer(self):
client = AsyncSimpleClient()
client.input_buffer = ['foo', 'bar']

10
tests/common/test_simple_client.py

@ -130,6 +130,16 @@ class TestSimpleClient:
client.client.call.assert_called_with('foo', 'bar', namespace='/',
timeout=60)
def test_call_timeout(self):
client = SimpleClient()
client.connected_event.set()
client.connected = True
client.client = mock.MagicMock()
client.client.call.side_effect = TimeoutError()
with pytest.raises(TimeoutError):
client.call('foo', 'bar')
def test_receive_with_input_buffer(self):
client = SimpleClient()
client.input_buffer = ['foo', 'bar']

Loading…
Cancel
Save