Support httpx2 in the test client
Merged
KL
5mo ago+32+32+01234567890123456789-7-7-0123456789
starlette.testclient now prefers httpx2 when installed, falling back to httpx. The fallback emits a StarletteDeprecationWarning urging migration; if neither is installed, the existing RuntimeError is raised pointing at httpx2.
Non-breaking: users with only httpx installed keep working, just warned.
- Adds
StarletteDeprecationWarning(UserWarning)tostarlette/exceptions.py(from #3119) - inherits fromUserWarningso it's visible by default. TYPE_CHECKINGguard keeps mypy typing againsthttpx(httpx2 has no stubs yet).
AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.