pytest-responses
py.test integration for responses
What it is and what it does
pytest-responses is a pytest plugin that integrates the responses HTTP mocking library into your test suite, automatically activating request interception across all tests by default. This prevents accidental network calls during testing and ensures your tests remain isolated and deterministic.
The plugin provides two main ways to control mocking: a responses fixture you can inject into test functions, and a withoutresponses marker to disable mocking for specific tests that genuinely need external network access. It depends on responses and pytest, both widely used testing tools, so integration into existing test workflows is straightforward.
Use it for:
- Prevent accidental HTTP requests in unit tests by automatically mocking all network calls.
- Test code that makes external API calls without hitting real endpoints or rate limits.
- Verify that your application makes the correct HTTP requests with the right parameters and headers.
- Run tests in isolated environments (CI/CD, offline) without network dependencies.
- Selectively disable mocking for integration tests that need real network access using the withoutresponses marker.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Automatically mocks HTTP requests across your pytest test suite using the responses library, preventing real network calls during testing.
Yes. This is a lightweight, actively maintained plugin that solves a common testing problem—network isolation—with minimal friction. Low dependency count, permissive license, and no known vulnerabilities make it a safe addition to test suites. Install it if your tests make HTTP requests and you want to mock them reliably.
Install
pytest-responses on PyPI
pip
pip install pytest-responsesuv
uv add pytest-responsespoetry
poetry add pytest-responsesInstalling pytest-responses
Before you install
Low friction install with only two runtime dependencies (responses and pytest). Actively maintained with a recent release; last commit 2026-06-29 and repository not archived.
License in practice
Licensed under Apache 2.0 (permissive), so you can use it freely in commercial and open-source projects without significant legal constraints.
Quickstart
pip install pytest-responses
import pytest
from responses import RequestsMock
def test_with_responses(responses):
responses.add(responses.GET, 'http://example.com', json={'key': 'value'})
# Your test code here
Requires Python 3.9 or later.
Verify before relying
- Whether the package works with all versions of the responses library or has specific version constraints.
- Whether the withoutresponses marker and responses fixture can be used together in the same test suite.
Package facts
| License | Apache 2.0 (permissive) |
| Python support | supports the current Python release (>=3.9) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — responses, pytest |
| Maintenance | actively maintained — 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 203,099/month — #9,635 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pytest_responses-0.6.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
httmockIntercepts and mocks HTTP requests made by the…
permissive · top 5,000 on PyPI
pytest-subprocessPytest plugin that intercepts and fakes…
permissive · top 15,000 on PyPI
responsesMocks HTTP requests made by the requests…
permissive · top 1,000 on PyPI
pytest_httpserverA pytest fixture and standalone context manager…
unclear · top 5,000 on PyPI
pytest-httpx2A pytest plugin that mocks httpx2 HTTP requests…
permissive · top 15,000 on PyPI
urllib3-mockMocks urllib3 HTTP requests in tests by…
permissive · top 15,000 on PyPI
aresponsesMocks external HTTP/HTTPS services for…
permissive · top 15,000 on PyPI
mocketMocket is a socket mocking framework that…
permissive · top 15,000 on PyPI
pytest-localserverProvides pytest fixtures that spin up local…
permissive · top 15,000 on PyPI
requests-mockIntercepts and mocks HTTP requests made through…
permissive · top 1,000 on PyPI