diff --git a/tests/test_aiodns.py b/tests/test_aiodns.py index 6872a18..d4728c3 100644 --- a/tests/test_aiodns.py +++ b/tests/test_aiodns.py @@ -19,11 +19,11 @@ class _TestAiodns: def test_dns_query(self): # This is not allowed to fail... - resolver = aiodns.DNSResolver(loop=self.loop) + resolver = aiodns.DNSResolver(["8.8.8.8", "8.8.4.4"], loop=self.loop) async def test(): async def query(name, query_type): - return await resolver.query(name, query_type) + return await resolver.query_dns(name, query_type) await query("google.com", "A") await query("httpbin.org", "A") diff --git a/tests/test_aiohttp.py b/tests/test_aiohttp.py index 9dd597e..a4ae1f9 100644 --- a/tests/test_aiohttp.py +++ b/tests/test_aiohttp.py @@ -9,6 +9,7 @@ import asyncio import sys import unittest +import warnings # Needed for suppressing aiohttp NotAppKeyWarning (temporary patch) import weakref from winloop import _testbase as tb @@ -78,16 +79,20 @@ async def on_shutdown(app): app = aiohttp.web.Application() app.router.add_get("/", websocket_handler) app.on_shutdown.append(on_shutdown) - app["websockets"] = weakref.WeakSet() + + with warnings.catch_warnings(): + # Just filter it for now. A workaround will be utilized in the future... + warnings.filterwarnings("ignore", category=aiohttp.web.NotAppKeyWarning) + app["websockets"] = weakref.WeakSet() - runner = aiohttp.web.AppRunner(app) + runner = aiohttp.web.AppRunner(app, shutdown_timeout=0.1) self.loop.run_until_complete(runner.setup()) site = aiohttp.web.TCPSite( runner, "0.0.0.0", 0, # https://github.com/aio-libs/aiohttp/pull/7188 - shutdown_timeout=0.1, + # shutdown_timeout=0.1, ) self.loop.run_until_complete(site.start()) port = site._server.sockets[0].getsockname()[1] diff --git a/winloop/_testbase.py b/winloop/_testbase.py index ccd3ffb..e568369 100644 --- a/winloop/_testbase.py +++ b/winloop/_testbase.py @@ -101,7 +101,8 @@ def setUp(self): self.__unhandled_exceptions = [] def tearDown(self): - self.loop.close() + if self.loop.is_closed: + self.loop.close() if self.__unhandled_exceptions: print("Unexpected calls to loop.call_exception_handler():") @@ -329,7 +330,6 @@ def setUp(self): def tearDown(self): if sys.platform != "win32" and sys.version_info < (3, 12): asyncio.set_child_watcher(None) - super().tearDown() def new_loop(self): return asyncio.new_event_loop()