--- id: pytest-localserver version: "0.10.0" license: MIT license_treatment: permissive maintenance: active --- # pytest-localserver — pytest plugin to test server connections locally. License: permissive · Maintenance: active · Downloads: 395.9K/mo ## 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 above — verify before relying. Provides pytest fixtures that spin up local HTTP and SMTP servers for testing code that makes real network requests without relying on external services or mocking. 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 pip install pytest-localserver uv add pytest-localserver poetry add pytest-localserver ## Installing pytest-localserver 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. 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("test", code=200) assert httpserver.url Requires pytest to be installed; the httpserver fixture is only available within pytest test functions. 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_current - Install friction: low - Maintenance: active - Downloads: 395.9K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest local server testing, mock http server pytest, test server localhost, pytest smtp server fixture, http request testing without mocking, pytest-plugin, integration-testing, http-testing [View on SkillFed](https://skillfed.io/packages/pytest-localserver) · [View on PyPI](https://pypi.org/project/pytest-localserver/)