skillfed

pytest-responses

py.test integration for responses

pytest-responses v0.6.0 203.1K downloads/30d#9,635 on PyPI94
Permissive license Apache 2.0 Active released

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-responses

uv

uv add pytest-responses

poetry

poetry add pytest-responses

Installing 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

Framework :: PytestIntended Audience :: DevelopersIntended Audience :: System AdministratorsOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9Topic :: Software Development

Tags

pytest http mockingmock http requests in testspytest responses integrationdisable network requests pytestfake http responses testingpytest network isolation
http-mockingtest-isolation

More Software Development packages