Skip to content

Commit b762072

Browse files
authored
Remove confusing test client alias (#3909)
* Remove confusing test client alias * Remove unused fixtures
1 parent 758cd0b commit b762072

File tree

2 files changed

+15
-29
lines changed

2 files changed

+15
-29
lines changed

tests/websockets/test_graphql_transport_ws.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ async def test_ws_message_frame_types_cannot_be_mixed(ws_raw: WebSocketClient):
153153
assert ws.close_reason == "WebSocket message type must be text"
154154

155155

156-
async def test_connection_init_timeout(
157-
request: object, http_client_class: type[HttpClient]
158-
):
156+
async def test_connection_init_timeout(http_client_class: type[HttpClient]):
159157
with contextlib.suppress(ImportError):
160158
from tests.http.clients.aiohttp import AioHttpClient
161159

@@ -206,9 +204,7 @@ async def test_connection_init_timeout_cancellation(
206204

207205

208206
@pytest.mark.xfail(reason="This test is flaky")
209-
async def test_close_twice(
210-
mocker: MockerFixture, request: object, http_client_class: type[HttpClient]
211-
):
207+
async def test_close_twice(mocker: MockerFixture, http_client_class: type[HttpClient]):
212208
test_client = http_client_class()
213209
test_client.create_app(connection_init_wait_timeout=timedelta(seconds=0.25))
214210

tests/websockets/test_graphql_ws.py

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ async def ws(ws_raw: WebSocketClient) -> AsyncGenerator[WebSocketClient, None]:
5252
assert ws.closed
5353

5454

55-
# convenience fixture to use previous name
56-
@pytest.fixture
57-
def aiohttp_app_client(http_client: HttpClient) -> HttpClient:
58-
return http_client
59-
60-
6155
async def test_simple_subscription(ws: WebSocketClient):
6256
await ws.send_legacy_message(
6357
{
@@ -292,9 +286,9 @@ async def test_context_can_be_modified_from_within_on_ws_connect(
292286
assert ws_raw.closed
293287

294288

295-
async def test_sends_keep_alive(aiohttp_app_client: HttpClient):
296-
aiohttp_app_client.create_app(keep_alive=True, keep_alive_interval=0.1)
297-
async with aiohttp_app_client.ws_connect(
289+
async def test_sends_keep_alive(http_client: HttpClient):
290+
http_client.create_app(keep_alive=True, keep_alive_interval=0.1)
291+
async with http_client.ws_connect(
298292
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
299293
) as ws:
300294
await ws.send_legacy_message({"type": "connection_init"})
@@ -655,15 +649,15 @@ async def test_resolving_enums(ws: WebSocketClient):
655649

656650

657651
@pytest.mark.xfail(reason="flaky test")
658-
async def test_task_cancellation_separation(aiohttp_app_client: HttpClient):
652+
async def test_task_cancellation_separation(http_client: HttpClient):
659653
# Note Python 3.7 does not support Task.get_name/get_coro so we have to use
660654
# repr(Task) to check whether expected tasks are running.
661655
# This only works for aiohttp, where we are using the same event loop
662656
# on the client side and server.
663657
try:
664658
from tests.http.clients.aiohttp import AioHttpClient
665659

666-
aio = aiohttp_app_client == AioHttpClient # type: ignore
660+
aio = http_client == AioHttpClient # type: ignore
667661
except ImportError:
668662
aio = False
669663

@@ -674,12 +668,8 @@ def get_result_handler_tasks():
674668
if "BaseGraphQLWSHandler.handle_async_results" in repr(task)
675669
]
676670

677-
connection1 = aiohttp_app_client.ws_connect(
678-
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
679-
)
680-
connection2 = aiohttp_app_client.ws_connect(
681-
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
682-
)
671+
connection1 = http_client.ws_connect("/graphql", protocols=[GRAPHQL_WS_PROTOCOL])
672+
connection2 = http_client.ws_connect("/graphql", protocols=[GRAPHQL_WS_PROTOCOL])
683673

684674
async with connection1 as ws1, connection2 as ws2:
685675
start_message: StartMessage = {
@@ -748,8 +738,8 @@ def get_result_handler_tasks():
748738
assert complete_message["id"] == "debug1"
749739

750740

751-
async def test_injects_connection_params(aiohttp_app_client: HttpClient):
752-
async with aiohttp_app_client.ws_connect(
741+
async def test_injects_connection_params(http_client: HttpClient):
742+
async with http_client.ws_connect(
753743
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
754744
) as ws:
755745
await ws.send_legacy_message(
@@ -791,8 +781,8 @@ async def test_injects_connection_params(aiohttp_app_client: HttpClient):
791781
assert ws.closed
792782

793783

794-
async def test_rejects_connection_params(aiohttp_app_client: HttpClient):
795-
async with aiohttp_app_client.ws_connect(
784+
async def test_rejects_connection_params(http_client: HttpClient):
785+
async with http_client.ws_connect(
796786
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
797787
) as ws:
798788
await ws.send_json(
@@ -813,9 +803,9 @@ async def test_rejects_connection_params(aiohttp_app_client: HttpClient):
813803

814804
@mock.patch.object(MyExtension, MyExtension.get_results.__name__, return_value={})
815805
async def test_no_extensions_results_wont_send_extensions_in_payload(
816-
mock: mock.MagicMock, aiohttp_app_client: HttpClient
806+
mock: mock.MagicMock, http_client: HttpClient
817807
):
818-
async with aiohttp_app_client.ws_connect(
808+
async with http_client.ws_connect(
819809
"/graphql", protocols=[GRAPHQL_WS_PROTOCOL]
820810
) as ws:
821811
await ws.send_legacy_message({"type": "connection_init"})

0 commit comments

Comments
 (0)