Skip to content

Commit

Permalink
Make tests a little more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Booth committed Apr 30, 2019
1 parent 142bcd9 commit a7f953e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion aiorpcx/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ def connection_lost(self, exc):
# Work around uvloop bug; see https://github.com/MagicStack/uvloop/issues/246
if self.transport:
self.transport = None
self.closed_event.set()
# Release waiting tasks
self._can_send.set()
# Cancelling directly leads to self-cancellation problems for member
# functions await-ing self.close()
self.loop.call_soon(self._task.cancel)
self.closed_event.set()

# External API
def is_send_buffer_full(self):
Expand Down Expand Up @@ -349,6 +349,7 @@ async def close(self, *, force_after=30):
except TaskTimeout:
self.abort()
await self.closed_event.wait()
await sleep(0)


class MessageSession(SessionBase):
Expand Down
3 changes: 0 additions & 3 deletions tests/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,6 @@ async def test_log_me(self, server, caplog):

class RPCClient(RPCSession):
# For tests of wire messages
def connection_made(self, transport):
self.transport = transport

async def send(self, item):
if not isinstance(item, str):
item = json.dumps(item)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_socks.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,9 @@ async def test_good_SOCKS4(self, proxy_address, auth):

@pytest.mark.asyncio
async def test_auto_detect_at_address_failure(self):
result = await SOCKSProxy.auto_detect_at_address('8.8.8.8:53', None)
assert result is None
async with ignore_after(1.0):
result = await SOCKSProxy.auto_detect_at_address('8.8.8.8:53', None)
assert result is None

@pytest.mark.asyncio
async def test_auto_detect_at_address_cannot_connect(self):
Expand Down

0 comments on commit a7f953e

Please sign in to comment.