Run the test suite on both AnyIO backends

KL
2mo ago
+189-223

Run the suite on both asyncio and trio, with backend-safe test isolation, deterministic synchronization, in-process transport hosting, and updated testing docs. This is now the final, test-only step: the production changes have been extracted into four focused PRs.

Stack

Review and merge in this order:

  1. #3540 - preserve request-stream ownership during server cleanup.
  2. #3541 - buffer replay and preserve the replay-to-live handoff.
  3. #3542 - bound direct subscription cleanup without delaying remote exits.
  4. #3543 - close client SSE iterators explicitly.
  5. This PR - enable both backends across the suite.

The base is #3543's branch so this diff contains only the remaining 13 files, with no production-code changes. Existing history is preserved with a merge commit, not rewritten. The subscription and client cleanups also passed standalone validation on main.

Blocker

Not ready to merge: HTTPX2 #1212, which closes nested response iterators, must merge and be released. Then update the SDK's HTTPX2 minimum and lockfile, and adjust the oversized-replay test helpers for the SSE event-size limit introduced after the current HTTPX2 2.5.0 pin.

Resource warnings remain errors. Trio's Linux-only pidfd encoding warning is filtered only in trio._subprocess, where the descriptor is never read as text.

Validation after splitting

All four prerequisite branches pass ./scripts/test on macOS/Python 3.14 with locked dependencies, 100% line/branch coverage, and strict-no-cover, without an HTTPX2 patch. Their focused regressions exercise both backends before suite-wide enablement.

This final branch passes Ruff lint/format and Pyright. Its locked-dependency full-suite run remains red with async-generator cleanup warnings: 11,565 passed, 381 failed, 15 errors, 17 skipped, 2 xfailed. The split does not resolve or suppress the upstream blocker.

Earlier validation before the split

With an isolated, uncommitted HTTPX2 cleanup patch, the original branch passed ./scripts/test on macOS/Python 3.14 with 11,966 passed, 17 skipped, 2 xfailed, 100% line/branch coverage, and strict-no-cover. Python 3.10 had 11,964 passed, 19 skipped, 2 xfailed. Testing against the upstream PR's actual source eliminated the async-generator warnings, with only two oversized-replay cases needing event-size-limit adjustments.

AI Disclaimer

This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.