diff --git a/tests/test_aiohttp.py b/tests/test_aiohttp.py index 3aeb2f9..44784ff 100644 --- a/tests/test_aiohttp.py +++ b/tests/test_aiohttp.py @@ -22,7 +22,7 @@ class _TestAioHTTP: return aiohttp.web.Response(text=PAYLOAD) asyncio.set_event_loop(self.loop) - app = aiohttp.web.Application(loop=self.loop) + app = aiohttp.web.Application() app.router.add_get('/', on_request) f = self.loop.create_server( @@ -33,6 +33,9 @@ class _TestAioHTTP: port = srv.sockets[0].getsockname()[1] async def test(): + # Make sure we're using the correct event loop. + self.assertIs(asyncio.get_event_loop(), self.loop) + for addr in (('localhost', port), ('127.0.0.1', port)): async with aiohttp.ClientSession() as client: diff --git a/tests/test_tcp.py b/tests/test_tcp.py index 927a328..dc1aaa8 100644 --- a/tests/test_tcp.py +++ b/tests/test_tcp.py @@ -823,7 +823,7 @@ class Test_UV_TCP(_TestTCP, tb.UVTestCase): super().data_received(data) self.transport.write(expected_response) - lsock = socket.socket() + lsock = socket.socket(socket.AF_INET) lsock.bind(('127.0.0.1', 0)) lsock.listen(1) addr = lsock.getsockname() @@ -835,7 +835,7 @@ class Test_UV_TCP(_TestTCP, tb.UVTestCase): def client(): nonlocal response try: - csock = socket.socket() + csock = socket.socket(socket.AF_INET) if client_ssl is not None: csock = client_ssl.wrap_socket(csock) csock.connect(addr) diff --git a/tests/test_udp.py b/tests/test_udp.py index fe3c4ec..78158a0 100644 --- a/tests/test_udp.py +++ b/tests/test_udp.py @@ -114,6 +114,9 @@ class _TestUDP: finally: if s_transport: s_transport.close() + # let it close + self.loop.run_until_complete( + asyncio.sleep(0.1, loop=self.loop)) def test_create_datagram_endpoint_sock(self): sock = None