Skip to content

Commit cca85c4

Browse files
authored
[PR #10675/048ef4c backport][3.12] Remove useless nonlocal statements in tests (#10678)
discovered by new flake8 in #10653 (cherry picked from commit 048ef4c)
1 parent d3c4543 commit cca85c4

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
@@ -315,7 +315,6 @@ async def test_concurrent_close(aiohttp_client) -> None:
315315
client_ws = None
316316

317317
async def handler(request):
318-
nonlocal client_ws
319318
ws = web.WebSocketResponse()
320319
await ws.prepare(request)
321320

@@ -936,7 +935,7 @@ async def delayed_send_frame(
936935
message: bytes, opcode: int, compress: Optional[int] = None
937936
) -> None:
938937
assert opcode == WSMsgType.PING
939-
nonlocal cancelled, ping_started
938+
nonlocal cancelled
940939
ping_started.set_result(None)
941940
try:
942941
await asyncio.sleep(1)

tests/test_helpers.py

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

353353
async def task_with_timeout() -> None:
354-
nonlocal ctx
355354
new_task = asyncio.current_task()
356355
assert new_task is not None
357356
with pytest.raises(asyncio.TimeoutError):

tests/test_web_server.py

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

349349
async def on_request(_: web.Request) -> web.Response:
350-
nonlocal event
351350
try:
352351
await asyncio.sleep(10)
353352
except asyncio.CancelledError:
@@ -389,7 +388,7 @@ async def test_no_handler_cancellation(unused_port_socket: socket.socket) -> Non
389388
started = False
390389

391390
async def on_request(_: web.Request) -> web.Response:
392-
nonlocal done_event, started, timeout_event
391+
nonlocal started
393392
started = True
394393
await asyncio.wait_for(timeout_event.wait(), timeout=5)
395394
done_event.set()

0 commit comments

Comments
 (0)