diff --git a/aries_cloudagent/transport/inbound/tests/test_http_transport.py b/aries_cloudagent/transport/inbound/tests/test_http_transport.py index 4a594f526d..c440fe7a57 100644 --- a/aries_cloudagent/transport/inbound/tests/test_http_transport.py +++ b/aries_cloudagent/transport/inbound/tests/test_http_transport.py @@ -71,7 +71,6 @@ def receive_message( def get_application(self): return self.transport.make_application() - @unittest_run_loop async def test_start_x(self): with async_mock.patch.object( test_module.web, "TCPSite", async_mock.MagicMock() @@ -82,7 +81,6 @@ async def test_start_x(self): with pytest.raises(test_module.InboundTransportSetupError): await self.transport.start() - @unittest_run_loop async def test_send_message(self): await self.transport.start() @@ -97,7 +95,6 @@ async def test_send_message(self): await self.transport.stop() - @unittest_run_loop async def test_send_receive_message(self): await self.transport.start() @@ -112,7 +109,6 @@ async def test_send_receive_message(self): await self.transport.stop() - @unittest_run_loop async def test_send_message_outliers(self): await self.transport.start() @@ -149,7 +145,6 @@ async def test_send_message_outliers(self): await self.transport.stop() - @unittest_run_loop async def test_invite_message_handler(self): await self.transport.start() diff --git a/aries_cloudagent/transport/inbound/tests/test_ws_transport.py b/aries_cloudagent/transport/inbound/tests/test_ws_transport.py index 472d69f50c..0e47bbecde 100644 --- a/aries_cloudagent/transport/inbound/tests/test_ws_transport.py +++ b/aries_cloudagent/transport/inbound/tests/test_ws_transport.py @@ -67,7 +67,6 @@ def receive_message( if self.result_event: self.result_event.set() - @unittest_run_loop async def test_start_x(self): with async_mock.patch.object( test_module.web, "TCPSite", async_mock.MagicMock() @@ -78,7 +77,6 @@ async def test_start_x(self): with pytest.raises(test_module.InboundTransportSetupError): await self.transport.start() - @unittest_run_loop async def test_message_and_response(self): await self.transport.start() diff --git a/aries_cloudagent/transport/outbound/tests/test_http_transport.py b/aries_cloudagent/transport/outbound/tests/test_http_transport.py index a8cc6bf344..0954f2b9d7 100644 --- a/aries_cloudagent/transport/outbound/tests/test_http_transport.py +++ b/aries_cloudagent/transport/outbound/tests/test_http_transport.py @@ -19,6 +19,7 @@ async def setUpAsync(self): self.profile = InMemoryProfile.test_profile() self.message_results = [] self.headers = {} + await super().setUpAsync() async def receive_message(self, request): payload = await request.json() @@ -34,7 +35,6 @@ async def get_application(self): app.add_routes([web.post("/", self.receive_message)]) return app - @unittest_run_loop async def test_handle_message_no_api_key(self): server_addr = f"http://localhost:{self.server.port}" @@ -49,7 +49,6 @@ async def send_message(transport, payload, endpoint): assert self.headers.get("x-api-key") is None assert self.headers.get("content-type") == "application/json" - @unittest_run_loop async def test_handle_message_api_key(self): server_addr = f"http://localhost:{self.server.port}" api_key = "test1234" @@ -68,7 +67,6 @@ async def send_message(transport, payload, endpoint, api_key): assert self.message_results == [{}] assert self.headers.get("x-api-key") == api_key - @unittest_run_loop async def test_handle_message_packed_compat_mime_type(self): server_addr = f"http://localhost:{self.server.port}" @@ -84,7 +82,6 @@ async def send_message(transport, payload, endpoint): assert self.message_results == [{}] assert self.headers.get("content-type") == "application/ssi-agent-wire" - @unittest_run_loop async def test_handle_message_packed_standard_mime_type(self): server_addr = f"http://localhost:{self.server.port}" @@ -101,7 +98,6 @@ async def send_message(transport, payload, endpoint): assert self.message_results == [{}] assert self.headers.get("content-type") == "application/didcomm-envelope-enc" - @unittest_run_loop async def test_stats(self): server_addr = f"http://localhost:{self.server.port}" @@ -122,7 +118,6 @@ async def send_message(transport, payload, endpoint): "outbound-http:POST": 1, } - @unittest_run_loop async def test_transport_coverage(self): transport = HttpTransport() assert transport.wire_format is None diff --git a/aries_cloudagent/transport/outbound/tests/test_ws_transport.py b/aries_cloudagent/transport/outbound/tests/test_ws_transport.py index 061f8f37df..12b2a98a75 100644 --- a/aries_cloudagent/transport/outbound/tests/test_ws_transport.py +++ b/aries_cloudagent/transport/outbound/tests/test_ws_transport.py @@ -13,6 +13,7 @@ class TestWsTransport(AioHTTPTestCase): async def setUpAsync(self): self.profile = InMemoryProfile.test_profile() self.message_results = [] + await super().setUpAsync() async def receive_message(self, request): ws = web.WebSocketResponse() @@ -35,7 +36,6 @@ async def get_application(self): app.add_routes([web.get("/", self.receive_message)]) return app - @unittest_run_loop async def test_handle_message(self): server_addr = f"ws://localhost:{self.server.port}" diff --git a/aries_cloudagent/utils/tests/test_http.py b/aries_cloudagent/utils/tests/test_http.py index 5a2886723b..e760769958 100644 --- a/aries_cloudagent/utils/tests/test_http.py +++ b/aries_cloudagent/utils/tests/test_http.py @@ -9,6 +9,7 @@ class TestTransportUtils(AioHTTPTestCase): async def setUpAsync(self): self.fail_calls = 0 self.succeed_calls = 0 + await super().setUpAsync() async def get_application(self): app = web.Application() @@ -31,7 +32,6 @@ async def succeed_route(self, request): ret = web.json_response([True]) return ret - @unittest_run_loop async def test_fetch_stream(self): server_addr = f"http://localhost:{self.server.port}" stream = await fetch_stream( @@ -41,7 +41,6 @@ async def test_fetch_stream(self): assert result == b"[true]" assert self.succeed_calls == 1 - @unittest_run_loop async def test_fetch_stream_default_client(self): server_addr = f"http://localhost:{self.server.port}" stream = await fetch_stream(f"{server_addr}/succeed") @@ -49,7 +48,6 @@ async def test_fetch_stream_default_client(self): assert result == b"[true]" assert self.succeed_calls == 1 - @unittest_run_loop async def test_fetch_stream_fail(self): server_addr = f"http://localhost:{self.server.port}" with self.assertRaises(FetchError): @@ -61,7 +59,6 @@ async def test_fetch_stream_fail(self): ) assert self.fail_calls == 2 - @unittest_run_loop async def test_fetch(self): server_addr = f"http://localhost:{self.server.port}" result = await fetch( @@ -70,14 +67,12 @@ async def test_fetch(self): assert result == [1] assert self.succeed_calls == 1 - @unittest_run_loop async def test_fetch_default_client(self): server_addr = f"http://localhost:{self.server.port}" result = await fetch(f"{server_addr}/succeed", json=True) assert result == [1] assert self.succeed_calls == 1 - @unittest_run_loop async def test_fetch_fail(self): server_addr = f"http://localhost:{self.server.port}" with self.assertRaises(FetchError): @@ -89,7 +84,6 @@ async def test_fetch_fail(self): ) assert self.fail_calls == 2 - @unittest_run_loop async def test_put_file(self): server_addr = f"http://localhost:{self.server.port}" with async_mock.patch("builtins.open", mock_open(read_data="data")): @@ -103,7 +97,6 @@ async def test_put_file(self): assert result == [1] assert self.succeed_calls == 1 - @unittest_run_loop async def test_put_file_default_client(self): server_addr = f"http://localhost:{self.server.port}" with async_mock.patch("builtins.open", mock_open(read_data="data")): @@ -116,7 +109,6 @@ async def test_put_file_default_client(self): assert result == [1] assert self.succeed_calls == 1 - @unittest_run_loop async def test_put_file_fail(self): server_addr = f"http://localhost:{self.server.port}" with async_mock.patch("builtins.open", mock_open(read_data="data")): diff --git a/aries_cloudagent/utils/tests/test_repeat.py b/aries_cloudagent/utils/tests/test_repeat.py index 63ac160867..0056334a8a 100644 --- a/aries_cloudagent/utils/tests/test_repeat.py +++ b/aries_cloudagent/utils/tests/test_repeat.py @@ -4,7 +4,7 @@ class TestRepeat(TestCase): - def test_iter(self): + async def test_iter(self): expect = [5, 7, 11, 17, 25] seq = test_module.RepeatSequence(5, interval=5.0, backoff=0.25) assert [round(attempt.next_interval) for attempt in seq] == expect @@ -12,9 +12,9 @@ def test_iter(self): seq = test_module.RepeatSequence(2, interval=5.0, backoff=0.25) attempt = seq.start() attempt = attempt.next() - attempt.timeout(interval=0.01) - with self.assertRaises(StopIteration): - attempt.next() + async with attempt.timeout(interval=0.01): + with self.assertRaises(StopIteration): + attempt.next() async def test_aiter(self): seq = test_module.RepeatSequence(5, interval=5.0, backoff=0.25) diff --git a/requirements.txt b/requirements.txt index fde3ab2124..30119fb677 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -aiohttp~=3.7.4 +aiohttp~=3.8.1 aiohttp-apispec~=2.2.1 aiohttp-cors~=0.7.0 apispec~=3.3.0 -async-timeout~=3.0.1 +async-timeout~=4.0.2 aioredis~=2.0.0 base58~=2.1.0 deepmerge~=0.3.0