From 575ca314f2fa2c7648100e140886ed70bdc10a2d Mon Sep 17 00:00:00 2001 From: Renn F Date: Sat, 12 Sep 2026 00:18:07 +0200 Subject: [PATCH] test: keep pytest collecting under anyio >= 4.15 (BlockingPortal deprecation) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit anyio 4.15 deprecates anyio.abc.BlockingPortal through a lazy import, and starlette 1.6.0 (the latest release) still imports that alias at module scope in testclient.py. Importing fastapi.testclient therefore emits a DeprecationWarning, and filterwarnings = ["error"] aborts pytest during collection (exit 2) before any test runs. This broke both our own CI and the guard-core ecosystem gate's guard-agent consumer job, whose fresh resolution admits anyio 4.15.x (the dev pin is anyio<4.16 since #53). Ignore exactly that warning until starlette ships its master fix (anyio.from_thread.BlockingPortal); the filter is a bridge, not a loophole — any other warning still fails the suite. --- pyproject.toml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 58fe791..a74c8c9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -133,7 +133,16 @@ testpaths = ["tests"] python_files = ["test_*.py"] asyncio_default_fixture_loop_scope = "function" addopts = "--cov=guard_agent --cov-branch --cov-report=term-missing" -filterwarnings = ["error"] +filterwarnings = [ + "error", + # starlette 1.6.0 still imports anyio.abc.BlockingPortal in testclient, which + # anyio >= 4.15 deprecates via a lazy import, so importing fastapi.testclient + # raises a DeprecationWarning at collection and the "error" filter aborts + # pytest before any test runs. starlette master already switched to + # anyio.from_thread.BlockingPortal; drop this filter once a starlette + # release carries it. + 'ignore:The anyio\.abc\.BlockingPortal alias is deprecated:DeprecationWarning', +] markers = [ "asyncio: mark tests as async" ]