Skip to content

Commit

Permalink
Fixed intermittent test failures (Fixes #572)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Oct 24, 2021
1 parent 32db48d commit db0565a
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions tests/asyncio/test_asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ def test_handle_reconnect(self, random, wait_for):
side_effect=[ValueError, exceptions.ConnectionError, None]
)
_run(c._handle_reconnect())
print(wait_for.mock.call_count) # logging to debug #572
print(wait_for.mock.call_args_list)
assert wait_for.mock.call_count == 3
assert [x[0][1] for x in asyncio.wait_for.mock.call_args_list] == [
1.5,
Expand All @@ -914,8 +912,6 @@ def test_handle_reconnect_max_delay(self, random, wait_for):
side_effect=[ValueError, exceptions.ConnectionError, None]
)
_run(c._handle_reconnect())
print(wait_for.mock.call_count) # logging to debug #572
print(wait_for.mock.call_args_list)
assert wait_for.mock.call_count == 3
assert [x[0][1] for x in asyncio.wait_for.mock.call_args_list] == [
1.5,
Expand All @@ -936,12 +932,7 @@ def test_handle_reconnect_max_attempts(self, random, wait_for):
c.connect = AsyncMock(
side_effect=[ValueError, exceptions.ConnectionError, None]
)
c.logger.setLevel('INFO')
_run(c._handle_reconnect())
c.logger.setLevel('ERROR')
print(c.reconnection_attempts)
print(wait_for.mock.call_count) # logging to debug #572
print(wait_for.mock.call_args_list)
assert wait_for.mock.call_count == 2
assert [x[0][1] for x in asyncio.wait_for.mock.call_args_list] == [
1.5,
Expand All @@ -957,15 +948,11 @@ def test_handle_reconnect_max_attempts(self, random, wait_for):
@mock.patch('socketio.client.random.random', side_effect=[1, 0, 0.5])
def test_handle_reconnect_aborted(self, random, wait_for):
c = asyncio_client.AsyncClient(logger=True)
c.logger.setLevel('INFO')
c._reconnect_task = 'foo'
c.connect = AsyncMock(
side_effect=[ValueError, exceptions.ConnectionError, None]
)
_run(c._handle_reconnect())
c.logger.setLevel('ERROR')
print(wait_for.mock.call_count) # logging to debug #572
print(wait_for.mock.call_args_list)
assert wait_for.mock.call_count == 2
assert [x[0][1] for x in asyncio.wait_for.mock.call_args_list] == [
1.5,
Expand Down Expand Up @@ -1069,7 +1056,7 @@ def test_handle_eio_message(self):
_run(c._handle_eio_message('9'))

def test_eio_disconnect(self):
c = asyncio_client.AsyncClient()
c = asyncio_client.AsyncClient(reconnection=False)
c.namespaces = {'/': '1'}
c.connected = True
c._trigger_event = AsyncMock()
Expand All @@ -1083,7 +1070,7 @@ def test_eio_disconnect(self):
assert not c.connected

def test_eio_disconnect_namespaces(self):
c = asyncio_client.AsyncClient()
c = asyncio_client.AsyncClient(reconnection=False)
c.namespaces = {'/foo': '1', '/bar': '2'}
c.connected = True
c._trigger_event = AsyncMock()
Expand Down

0 comments on commit db0565a

Please sign in to comment.