1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING
4+
15import pytest
26import pytest_asyncio
37from aiohttp import web
610
711from .utils import number
812
13+ if TYPE_CHECKING :
14+ from aiohttp .test_utils import TestClient
15+ from pytest_aiohttp .plugin import AiohttpClient
16+
917
1018@pytest_asyncio .fixture ()
11- async def client (aiohttp_client ): # type: ignore
19+ async def client (aiohttp_client : AiohttpClient ) -> TestClient :
1220 app = web .Application ()
1321 app .router .add_get ("/" , main .index )
1422 app .router .add_get ("/health" , main .health )
@@ -17,7 +25,7 @@ async def client(aiohttp_client): # type: ignore
1725
1826
1927@pytest .mark .asyncio
20- async def test_ping (client ): # type: ignore
28+ async def test_ping (client : TestClient ) -> None :
2129 headers = {"X-GitHub-Event" : "ping" , "X-GitHub-Delivery" : "1234" }
2230 data = {"zen" : "testing is good" }
2331 response = await client .post ("/" , headers = headers , json = data )
@@ -26,15 +34,15 @@ async def test_ping(client): # type: ignore
2634
2735
2836@pytest .mark .asyncio
29- async def test_failure (client ): # type: ignore
37+ async def test_failure (client : TestClient ) -> None :
3038 # Even in the face of an exception, the server should not crash.
3139 # Missing key headers.
3240 response = await client .post ("/" , headers = {})
3341 assert response .status == 500
3442
3543
3644@pytest .mark .asyncio
37- async def test_success (client ): # type: ignore
45+ async def test_success (client : TestClient ) -> None :
3846 headers = {"X-GitHub-Event" : "project" , "X-GitHub-Delivery" : "1234" }
3947 # Sending a payload that shouldn't trigger any networking, but no errors
4048 # either.
@@ -44,15 +52,15 @@ async def test_success(client): # type: ignore
4452
4553
4654@pytest .mark .asyncio
47- async def test_index (client ): # type: ignore
55+ async def test_index (client : TestClient ) -> None :
4856 response = await client .get ("/" )
4957 assert response .status == 200
5058 assert response .headers ["content-type" ] == "text/html"
5159 assert "algorithms-keeper" in (await response .text ())
5260
5361
5462@pytest .mark .asyncio
55- async def test_health (client ): # type: ignore
63+ async def test_health (client : TestClient ) -> None :
5664 response = await client .get ("/health" )
5765 assert response .status == 200
5866 assert await response .text () == "OK"
0 commit comments