chore(deps): run the test client on httpx2 instead of httpx - #96
Merged
Merged
Conversation
Starlette 1.7 deprecates driving starlette.testclient with httpx and warns to install httpx2. Nothing imports httpx directly, so the dev group only needs the package swapped. Test-only; the library's dependencies are unchanged.
httpx2 types Headers.get() as str | None, so the ETag passed back as If-None-Match and the Cache-Control string no longer type-checked. Both headers must be present, so index them instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Starlette 1.7 deprecates using
httpxwithstarlette.testclient:If a later Starlette drops
httpxsupport, the whole test suite would break.Change
devdependency group,httpx>=0.28.1is replaced byhttpx2>=2.13.1.fastapi_cachex/ortests/importshttpxdirectly;TestClientpicks uphttpx2on its own.uv.lockswaps httpx/httpcore for httpx2/httpcore2. certifi drops out, and truststore and httpx2-jsfetch come in.Verification
uv run pytest -W error::DeprecationWarning:starlette.testclient: 540 passed and 153 skipped. The skips are the Redis/Memcached live suites; no test servers were running.uv run tox -p auto: py310, py311, py312, py313 and py314 all pass. The py310 env has httpx2 2.13.1 with Starlette 1.7.0.uv lock --checkpasses.cd0f582: httpx2 typesHeaders.get()asstr | None, which brokemypy testsin two places intests/test_cache_hit.py. Both headers must be present, so they are now read by subscript. Every step oflint.yml(ruff check and format,mypy --stricton the package,mypy tests,mypy scripts) now passes locally.