pytest_httpserver
pytest-httpserver is a httpserver for pytest
Decision gist · record as of 2026-08-14
Yes, if you need to test HTTP clients. The package is actively maintained, has low install friction, and fills a clear testing gap. The only caveat is the unclear license status—verify the actual license before use in proprietary projects. For open-source work or internal testing, it is a solid choice.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.10 or later.
- Low friction install with a single runtime dependency (Werkzeug).
- Actively maintained with recent commits and steady releases since 2018.
License · maintenance · safety
(unclear) — License status is unclear—no SPDX identifier or raw license text is declared in the package metadata, so you should verify the actual license terms before use in proprietary or restricted contexts.
last release 2026-02-14 (181 days) · last repo commit 2026-08-10 · 253 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,898,973 downloads/mo, #2,457 on PyPI
Alternatives
Verify before relying
pip install pytest-httpserver
import pytest
from pytest_httpserver import HTTPServer
def test_client(httpserver):
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
# Your HTTP client code here
assert requests.get(httpserver.url_for("/foobar")).json() == {"foo": "bar"}- Whether the package is licensed under an open-source or proprietary license (license metadata is missing).
- Whether error responses and edge cases can be simulated (not explicitly stated in the fact sheet).
What it is and what it does
pytest-httpserver provides a pytest fixture and standalone context manager that starts a local HTTP server to intercept and respond to client requests during tests. Instead of mocking individual HTTP calls, you define expectations—matching on URI, method, headers, query strings, and request body—and specify what response the server should send back. The server can handle permanent expectations (served repeatedly), one-shot expectations (served once), and ordered expectations (served in strict sequence). Responses can be raw data, JSON, Werkzeug Response objects, or custom functions.
The package is built on Werkzeug for HTTP parsing and request/response handling. It works both as a pytest fixture (automatically started and stopped around each test) and as a standalone context manager for non-pytest code. This approach lets you test HTTP clients in isolation without external network calls, making tests faster and more reliable.
Use it for
- Test an HTTP client library by mocking server responses without running a real server.
- Verify that your code sends the correct HTTP method, headers, and body to an API.
- Test ordered sequences of requests in a single test, ensuring your client makes calls in the right order.
- Run integration tests in CI/CD pipelines where external HTTP services may be unavailable.
- Use the standalone context manager in non-pytest code to set up temporary HTTP server expectations.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to test HTTP clients.
The package is actively maintained, has low install friction, and fills a clear testing gap. The only caveat is the unclear license status—verify the actual license before use in proprietary projects. For open-source work or internal testing, it is a solid choice.
Install
pytest-httpserver on PyPI
Before you install
Low friction install with a single runtime dependency (Werkzeug). Actively maintained with recent commits and steady releases since 2018.
Requires Python 3.10 or later.
License in practice
License status is unclear—no SPDX identifier or raw license text is declared in the package metadata, so you should verify the actual license terms before use in proprietary or restricted contexts.
Quickstart
pip install pytest-httpserver
import pytest
from pytest_httpserver import HTTPServer
def test_client(httpserver):
httpserver.expect_request("/foobar").respond_with_json({"foo": "bar"})
# Your HTTP client code here
assert requests.get(httpserver.url_for("/foobar")).json() == {"foo": "bar"}
Verify before relying
- Whether the package is licensed under an open-source or proprietary license (license metadata is missing).
- Whether error responses and edge cases can be simulated (not explicitly stated in the fact sheet).
Package facts
| License | Not declared unclear |
| Python support | Supports the current Python release >=3.10 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageWerkzeug |
| Maintenance | Actively maintained 181 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,898,973 / month, #2,457 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 3 - AlphaFramework :: PytestIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Software Development :: Libraries :: Python Modules |
Evidence: pytest_httpserver-1.1.5-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “fake http server testing”
- pytest_httpserverA pytest fixture and standalone context manager that runs a fake HTTP…
- fakesnowRuns a fake Snowflake database locally for testing, either by…
- urllib3-mockMocks urllib3 HTTP requests in tests by intercepting calls and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also pytest-httpx2 · pytest-localserver · pytest-responses · pytest-httpbin · responses · urllib3-mock · aiointercept · pytest-subprocess · mocket · httmock