Skip to content

Commit 93cc828

Browse files
committed
test: mark the resumption-token test's post-exit line lax-no-cover for 3.11
CPython gh-106749 (wontfix on 3.11): coro.throw() omits the call trace event, desyncing coverage.py's CTracer so the first plain statement after a ClientSession/streamable_http_client __aexit__ is dropped. Restructures only relocate the miss (verified empirically across five variants); name the upstream bug and sanction lax-no-cover for this case in the README.
1 parent 2ee59b7 commit 93cc828

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

tests/interaction/README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,14 @@ assert after the call, with no synchronisation. The exceptions:
209209
CI requires 100% line and branch coverage, including `tests/`, and `strict-no-cover` fails the
210210
build if a line marked `# pragma: no cover` is ever executed. When a new test starts covering a
211211
pragma'd line in `src/`, delete the pragma in the same change. Do not add new `# type: ignore` or
212-
`# noqa` comments; restructure instead. The one sanctioned pragma in this suite's test code is
213-
`# pragma: no branch` on a `with`/`async with` line whose only fault is coverage.py mis-tracing
214-
the exit arc of a nested async context — restructure first, and reserve the pragma for shapes
215-
that cannot collapse (a sync `with` adjacent to an `async with`).
212+
`# noqa` comments; restructure instead. Two pragmas are sanctioned in this suite's test code, both
213+
for known-upstream tracer bugs and only after restructuring has been tried: `# pragma: no branch`
214+
on a `with`/`async with` line whose only fault is coverage.py mis-tracing the exit arc of a nested
215+
async context (reserve it for shapes that cannot collapse — a sync `with` adjacent to an
216+
`async with`); and `# pragma: lax no cover` on a single statement that 3.11's tracer drops because
217+
the preceding `async with` unwinds via `coro.throw()` (python/cpython#106749, wontfix on 3.11) —
218+
this hits any test that must run statements after a `ClientSession`/`streamable_http_client` exits
219+
but still inside an outer `async with`, and no restructure can avoid it.
216220

217221
A handful of `# pragma: lax no cover` markers in `src/` cover teardown exception handlers whose
218222
execution is timing-dependent under the in-process HTTP bridge — the POST-stream and

tests/interaction/transports/test_hosting_resume.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ async def collect(params: LoggingMessageNotificationParams) -> None:
358358
tg.cancel_scope.cancel()
359359

360360
with anyio.fail_after(5): # pragma: no branch
361-
release.set()
361+
release.set() # pragma: lax no cover — python/cpython#106749: 3.11 drops this line event
362362
# init priming + init response + call priming + "first" + "second" + result = 6 stored events.
363363
await store.wait_until_stored(6)
364364
async with ( # pragma: no branch

0 commit comments

Comments
 (0)