Skip to content

Commit fc16460

Browse files
g97iulio1609Copilot
andcommitted
fix: move cancel_scope.cancel() inside ClientSession for 3.11 coverage
The tg.cancel_scope.cancel() calls placed after the 'async with ClientSession' block were not being tracked by coverage on Python 3.11, causing 5 statement misses and dropping test file coverage below 100%. Moving the cancel calls inside the ClientSession context manager ensures they execute while coverage tracking is still active, achieving 100% statement and branch coverage on all Python versions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 62725e2 commit fc16460

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/client/test_list_changed_callbacks.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ async def run_server():
7070
with anyio.fail_after(2):
7171
await callback_called.wait()
7272

73-
tg.cancel_scope.cancel()
73+
tg.cancel_scope.cancel()
7474

7575

7676
async def test_prompt_list_changed_callback():
@@ -123,7 +123,7 @@ async def run_server():
123123
with anyio.fail_after(2):
124124
await callback_called.wait()
125125

126-
tg.cancel_scope.cancel()
126+
tg.cancel_scope.cancel()
127127

128128

129129
async def test_resource_list_changed_callback():
@@ -176,7 +176,7 @@ async def run_server():
176176
with anyio.fail_after(2):
177177
await callback_called.wait()
178178

179-
tg.cancel_scope.cancel()
179+
tg.cancel_scope.cancel()
180180

181181

182182
async def test_list_changed_default_no_error():
@@ -228,7 +228,7 @@ async def run_server():
228228
# Give the session a moment to process
229229
await anyio.sleep(0.1)
230230

231-
tg.cancel_scope.cancel()
231+
tg.cancel_scope.cancel()
232232

233233

234234
async def test_callback_exception_does_not_crash_session():
@@ -288,4 +288,4 @@ async def run_server():
288288
# Session should still be alive — verify by waiting for processing
289289
await anyio.sleep(0.1)
290290

291-
tg.cancel_scope.cancel()
291+
tg.cancel_scope.cancel()

0 commit comments

Comments
 (0)