diff --git a/tests/test_fastapi.py b/tests/test_fastapi.py index 7eceb5f..5cd621e 100644 --- a/tests/test_fastapi.py +++ b/tests/test_fastapi.py @@ -1,5 +1,6 @@ import asyncio import socket +import sys from typing import Any, Optional import fastapi @@ -56,7 +57,10 @@ def dispatch_test_init(self, reg: Registry) -> str: self.sockets = [sock] self.uvicorn = uvicorn.Server(config) self.runner = Runner() - self.event = asyncio.Event() + if sys.version_info > (3, 8): + self.event = asyncio.Event() + else: + self.event = asyncio.Event(loop=self.runner.get_loop()) return f"http://{host}:{port}" def dispatch_test_run(self): diff --git a/tests/test_http.py b/tests/test_http.py index 34d27ab..9271b22 100644 --- a/tests/test_http.py +++ b/tests/test_http.py @@ -1,5 +1,6 @@ import asyncio import socket +import sys from http.server import HTTPServer import dispatch.test @@ -41,11 +42,15 @@ def dispatch_test_init(self, reg: Registry) -> str: host = "127.0.0.1" port = 0 - self.aiowait = asyncio.Event() self.aioloop = Runner() self.aiohttp = Server(host, port, Dispatch(reg)) self.aioloop.run(self.aiohttp.start()) + if sys.version_info > (3, 8): + self.aiowait = asyncio.Event() + else: + self.aiowait = asyncio.Event(loop=self.aioloop.get_loop()) + return f"http://{self.aiohttp.host}:{self.aiohttp.port}" def dispatch_test_run(self):