From 35bc06daaefe1ae68366565fe9db158028504392 Mon Sep 17 00:00:00 2001 From: Artur Shiriev Date: Sun, 27 Sep 2026 19:28:27 +0300 Subject: [PATCH] chore: give every coverage pragma a reason (TS6) --- examples/app.py | 2 +- tests/test_aio.py | 7 ++----- tests/test_inject.py | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/examples/app.py b/examples/app.py index 5b4492f..cff6aa2 100644 --- a/examples/app.py +++ b/examples/app.py @@ -51,7 +51,7 @@ def build_server(port: str = "127.0.0.1:0") -> tuple[grpc.Server, int, Container return server, bound_port, container -if __name__ == "__main__": # pragma: no cover +if __name__ == "__main__": # pragma: no cover - script entry point; tests call build_server() directly _server, _port, _container = build_server("[::]:50051") print(f"Serving on port {_port}; Ctrl+C to stop") # noqa: T201 try: diff --git a/tests/test_aio.py b/tests/test_aio.py index 7e70ad6..fa8921b 100644 --- a/tests/test_aio.py +++ b/tests/test_aio.py @@ -142,11 +142,8 @@ async def test_aio_app_finalizer_runs_on_root_close() -> None: stub = greeter_pb2_grpc.GreeterStub(channel) await stub.SayHello(HelloRequest(name="x")) await server.stop(0) - # coveragepy #2124: on Python 3.11 the tracer can lose 1-2 lines right after awaiting - # a coroutine that cancels tasks internally, which server.stop does to its own - # background tasks. Excluded (not skipped) so the flake can't fail --cov-fail-under. - await container.close_async() # pragma: no cover - assert app_teardowns == ["app-closed"] # pragma: no cover + await container.close_async() # pragma: no cover - coveragepy #2124: 3.11 can drop lines after server.stop + assert app_teardowns == ["app-closed"] # pragma: no cover - coveragepy #2124: 3.11 can drop lines after server.stop async def test_wrap_unary_aio_resets_context_var_when_close_raises() -> None: diff --git a/tests/test_inject.py b/tests/test_inject.py index 975ce60..2f2f014 100644 --- a/tests/test_inject.py +++ b/tests/test_inject.py @@ -51,7 +51,7 @@ def test_inject_raises_without_interceptor() -> None: def method( _self: object, _request: str, _context: object, _app_res: typing.Annotated[AppResource, FromDI(AppResource)] ) -> None: - pass # pragma: no cover + pass # pragma: no cover - never runs; inject raises before the call without DIInterceptor def _call() -> None: with pytest.raises(RuntimeError, match="DIInterceptor"):