Skip to content

chore(deps): run the test client on httpx2 instead of httpx - #96

Merged
allen0099 merged 2 commits into
masterfrom
chore/httpx2-test-client
Sep 25, 2026
Merged

allen0099 merged 2 commits into
masterfrom
chore/httpx2-test-client

Conversation

@allen0099

@allen0099 allen0099 commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Why

Starlette 1.7 deprecates using httpx with starlette.testclient:

DeprecationWarning: Using httpx with starlette.testclient is deprecated; install httpx2 instead.

If a later Starlette drops httpx support, the whole test suite would break.

Change

  • In the dev dependency group, httpx>=0.28.1 is replaced by httpx2>=2.13.1.
  • Nothing in fastapi_cachex/ or tests/ imports httpx directly; TestClient picks up httpx2 on its own.
  • uv.lock swaps httpx/httpcore for httpx2/httpcore2. certifi drops out, and truststore and httpx2-jsfetch come in.
  • This is test-only: the library's runtime dependencies and extras are unchanged, so there is no changelog entry.

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.
  • The warning no longer appears.
  • 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 --check passes.
  • Follow-up cd0f582: httpx2 types Headers.get() as str | None, which broke mypy tests in two places in tests/test_cache_hit.py. Both headers must be present, so they are now read by subscript. Every step of lint.yml (ruff check and format, mypy --strict on the package, mypy tests, mypy scripts) now passes locally.

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.
@allen0099
allen0099 merged commit 8091df2 into master Sep 25, 2026
10 checks passed
@allen0099
allen0099 deleted the chore/httpx2-test-client branch September 25, 2026 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant