Skip to content

Commit 048ef4c

Browse files
authored
Remove useless nonlocal statements in tests (#10675)
discovered by new flake8 in #10653
1 parent 35c979b commit 048ef4c

File tree

3 files changed

+2
-5
lines changed

3 files changed

+2
-5
lines changed

tests/test_client_ws_functional.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ async def test_concurrent_close(aiohttp_client: AiohttpClient) -> None:
363363
client_ws: Optional[aiohttp.ClientWebSocketResponse] = None
364364

365365
async def handler(request: web.Request) -> web.WebSocketResponse:
366-
nonlocal client_ws
367366
ws = web.WebSocketResponse()
368367
await ws.prepare(request)
369368

@@ -960,7 +959,7 @@ async def delayed_send_frame(
960959
message: bytes, opcode: int, compress: Optional[int] = None
961960
) -> None:
962961
assert opcode == WSMsgType.PING
963-
nonlocal cancelled, ping_started
962+
nonlocal cancelled
964963
ping_started.set_result(None)
965964
try:
966965
await asyncio.sleep(1)

tests/test_helpers.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ async def test_timer_context_timeout_does_swallow_cancellation() -> None:
378378
ctx = helpers.TimerContext(loop)
379379

380380
async def task_with_timeout() -> None:
381-
nonlocal ctx
382381
new_task = asyncio.current_task()
383382
assert new_task is not None
384383
with pytest.raises(asyncio.TimeoutError):

tests/test_web_server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ async def test_handler_cancellation(unused_port_socket: socket.socket) -> None:
384384
port = sock.getsockname()[1]
385385

386386
async def on_request(request: web.Request) -> web.Response:
387-
nonlocal event
388387
try:
389388
await asyncio.sleep(10)
390389
except asyncio.CancelledError:
@@ -427,7 +426,7 @@ async def test_no_handler_cancellation(unused_port_socket: socket.socket) -> Non
427426
started = False
428427

429428
async def on_request(request: web.Request) -> web.Response:
430-
nonlocal done_event, started, timeout_event
429+
nonlocal started
431430
started = True
432431
await asyncio.wait_for(timeout_event.wait(), timeout=5)
433432
done_event.set()

0 commit comments

Comments
 (0)