Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/test_aiodns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 8 additions & 3 deletions tests/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions winloop/_testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():")
Expand Down Expand Up @@ -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()
Expand Down
Loading