skillfed

pytest-recording

A pytest plugin powered by VCR.py to record and replay HTTP traffic

pytest-recording v0.13.4 6.1M downloads/30d#1,966 on PyPI615
Permissive license MIT Active released

What it is and what it does

pytest-recording is a pytest plugin that integrates vcrpy to record HTTP interactions during test runs and replay them on subsequent runs. Instead of mocking HTTP responses manually or hitting live APIs in tests, you decorate test functions with @pytest.mark.vcr and the plugin automatically captures requests and responses into YAML cassette files, then replays them without network access. This makes tests faster, more reliable, and independent of external services.

The plugin offers straightforward configuration through pytest marks and fixtures, supports combining multiple cassettes, can block network access entirely to prevent accidental live requests, and includes a rewrite mode to regenerate cassettes from scratch. It integrates with vcrpy's full API, allowing custom matchers, persisters, and fine-grained control over what gets recorded and filtered.

Use it for:

  • Test code that calls external APIs without making real network requests during CI/CD runs
  • Record API responses once, then run tests offline or in isolated environments
  • Prevent tests from failing due to external service downtime or rate limiting
  • Block network access globally to catch unintended HTTP calls in your test suite
  • Filter sensitive headers or query parameters from cassettes before committing them to version control

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

A pytest plugin that records and replays HTTP traffic using VCR.py, letting you test code that makes network requests without hitting the network every time.

Yes. This is a well-maintained, actively developed plugin with no security issues, low install friction, and a clear use case for any project testing code that makes HTTP requests. The permissive MIT license poses no barrier. Install it if you want to replace live API calls or manual mocks with recorded cassettes in pytest.

Install

pytest-recording on PyPI

pip

pip install pytest-recording

uv

uv add pytest-recording

poetry

poetry add pytest-recording

Installing pytest-recording

Before you install

Low friction install with just two runtime dependencies (pytest and vcrpy). Actively maintained with recent commits and no known vulnerabilities. Supports Python 3.9 through 3.13.

License in practice

MIT license is permissive; you can use this in commercial projects with minimal restrictions.

Quickstart

pip install pytest-recording

import pytest

@pytest.mark.vcr
def test_api_call():
    # Your test code that uses pytest and vcrpy
    pass

# Run with: pytest --record-mode=once test_file.py

Requires pytest and vcrpy as runtime dependencies. Default recording mode is 'none' to prevent unintentional network requests; you must pass --record-mode=once (or another mode) to pytest to allow recording on first run.

Verify before relying

  • Whether the plugin works with pytest fixtures beyond vcr_config and the vcr cassette object itself
  • Performance characteristics when replaying large cassette files or many simultaneous tests
  • Exact HTTP status codes or response assertions supported in decorated test functions

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies 2 — pytest, vcrpy
Maintenance actively maintained — 463 days since the last release
Last repo commit
First released
Downloads 6,134,948/month — #1,966 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: pytest_recording-0.13.4-py3-none-any.whl

Keywords: mock, network, pytest, vcr

Development Status :: 4 - BetaFramework :: PytestIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming 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.9Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Software Development :: TestingTyping :: Typed

Tags

pytest http mocking vcrrecord replay http requestspytest network cassettesvcr pytest pluginhttp traffic recording testsmock http responses pytestnetwork isolation testing
http-mockingtest-isolationvcr-integration

More Testing packages