pytest-localserver
pytest plugin to test server connections locally.
Decision gist · record as of 2026-08-14
Yes. Low install friction, actively maintained, no known vulnerabilities, and solves a real testing problem—letting you test network-dependent code with a real local server rather than mocks.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires pytest to be installed; the httpserver fixture is only available within pytest test functions.
- Low friction install with a single runtime dependency (werkzeug).
- Actively maintained with recent releases; last commit was 2026-07-14 and the package is marked active.
License · maintenance · safety
MIT (permissive) — MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
last release 2025-11-24 (263 days) · last repo commit 2026-07-14 · 37 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 395,896 downloads/mo, #6,978 on PyPI
Alternatives
Verify before relying
pip install pytest-localserver
def test_scrape(httpserver):
httpserver.serve_content("<html>test</html>", code=200)
assert httpserver.url- Whether the package handles urllib, requests, and other HTTP libraries as described in the documentation.
What it is and what it does
pytest-localserver is a pytest plugin that provides fixtures for running local HTTP and SMTP servers during tests. Instead of mocking HTTP calls or relying on external test servers, you get a real server running on localhost that you can control—setting response codes, headers, content, and inspecting incoming requests. It works with werkzeug to handle the underlying HTTP protocol.
The plugin includes httpserver and httpsserver fixtures for HTTP/HTTPS testing, plus an smtpserver fixture for testing mail-sending code. You configure what each server should return, make your code talk to it, and then verify the requests were made correctly. It also supports running a WSGI application on the test server, making it flexible for testing against different backend behaviors.
Use it for
- Test a web scraper or API client against a controlled local server instead of a live endpoint.
- Verify your code handles HTTP error responses gracefully without external dependencies.
- Test email-sending code by inspecting what was posted to a local SMTP server.
- Test request headers and POST data handling by examining the server's received requests.
- Run integration tests for code that makes network calls without mocking the underlying HTTP layer.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
Low install friction, actively maintained, no known vulnerabilities, and solves a real testing problem—letting you test network-dependent code with a real local server rather than mocks.
Install
pytest-localserver on PyPI
Before you install
Low friction install with a single runtime dependency (werkzeug). Actively maintained with recent releases; last commit was 2026-07-14 and the package is marked active.
Requires pytest to be installed; the httpserver fixture is only available within pytest test functions.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most projects.
Quickstart
pip install pytest-localserver
def test_scrape(httpserver):
httpserver.serve_content("<html>test</html>", code=200)
assert httpserver.url
Verify before relying
- Whether the package handles urllib, requests, and other HTTP libraries as described in the documentation.
Package facts
| License | MIT permissive |
| Python support | Supports the current Python release >=3.7 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagewerkzeug |
| Maintenance | Actively maintained 263 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 395,896 / month, #6,978 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Testing |
Evidence: pytest_localserver-0.10.0-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 › “pytest local server testing”
- pytest-localserverProvides pytest fixtures that spin up local HTTP and SMTP servers for…
- pytest-httpbinProvides a pytest fixture that runs a local httpbin server in a test…
- pytest-localftpserverProvides pytest fixtures for running local FTP and TLS-FTP servers in…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-httpbin · pytest-sftpserver · pytest_httpserver · pytest-responses · mocket · pytest-django · pytest-base-url · pytest-mock-resources · pytest-docker