starlette-testclient
A backport of Starlette TestClient using requests! ⏪️
What it is and what it does
starlette-testclient is a backport of Starlette's TestClient that swaps out httpx for requests as the underlying HTTP library. It exists as a migration aid: if your codebase still uses requests for testing and you're not ready to switch to httpx, this package lets you keep that pattern without forking Starlette's test utilities. You import from starlette_testclient instead of starlette.testclient and get the same TestClient interface backed by requests.
The package depends on requests and starlette as runtime libraries and supports Python 3.7 through 3.12. It is classified as Alpha and has not been actively maintained for over two years, so it functions as a compatibility shim rather than an evolving tool. No known security vulnerabilities are recorded.
Use it for:
- Testing applications in codebases that standardize on requests and cannot yet migrate to httpx.
- Gradual migration: use this backport while transitioning test suites from requests to httpx-based clients.
- Legacy projects: maintain existing test patterns in older applications without rewriting test infrastructure.
- Minimal dependency footprint: avoid adding httpx to projects that already have requests as a core dependency.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides a drop-in replacement for Starlette's TestClient that uses requests instead of httpx for testing Starlette applications.
Yes, if you are actively migrating away from this package or need a temporary requests-based TestClient for an existing codebase. No, if you are starting a new project—use the native httpx-based TestClient instead. The dormant maintenance status means this is a bridge tool, not a long-term solution; plan to migrate to the standard TestClient.
Install
starlette-testclient on PyPI
pip
pip install starlette-testclientuv
uv add starlette-testclientpoetry
poetry add starlette-testclientInstalling starlette-testclient
Before you install
Low friction: pure Python wheel with only two runtime dependencies (requests and starlette). Maintenance is dormant—last release was 837 days ago—so expect no active updates or bug fixes.
License in practice
BSD 3-Clause permissive license means you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install starlette-testclient
from starlette_testclient import TestClient
Verify before relying
- Whether this backport remains compatible with current starlette versions beyond the last release date.
- Whether requests-based testing covers all httpx-specific behaviors needed for comprehensive testing.
Package facts
| License | not declared (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — requests, starlette |
| Maintenance | dormant — 837 days since the last release |
| First released | |
| Downloads | 2,751,808/month — #2,906 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: starlette_testclient-0.4.1-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
async-asgi-testclientProvides an async test client for ASGI web…
permissive · top 15,000 on PyPI
starletteStarlette is a lightweight ASGI framework for…
permissive · top 100 on PyPI
aiohttp-asgi-connectorProvides an AIOHTTP connector that lets you…
permissive · top 15,000 on PyPI
apimatic-requests-client-adapterProvides a requests-based HTTP client adapter…
permissive · top 15,000 on PyPI
starlette-cramjamMiddleware for Starlette that compresses HTTP…
permissive · top 15,000 on PyPI
starlette-prometheusAdds Prometheus metrics collection and exposure…
copyleft · top 15,000 on PyPI
opentelemetry-instrumentation-starletteAdds automatic tracing and observability…
permissive · top 5,000 on PyPI
starlette-contextMiddleware for Starlette that stores and…
permissive · top 5,000 on PyPI
SecwebSecweb applies security headers (CSP, HSTS,…
copyleft · top 15,000 on PyPI
niquestsNiquests is a drop-in replacement for Requests…
permissive · top 5,000 on PyPI