pytest-recording
A pytest plugin powered by VCR.py to record and replay HTTP traffic
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-recordinguv
uv add pytest-recordingpoetry
poetry add pytest-recordingInstalling 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
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pytest-vcrA pytest plugin that integrates VCR.py to…
permissive · top 5,000 on PyPI
betamaxBetamax records and replays HTTP interactions…
permissive · top 15,000 on PyPI
keboola.vcrRecords, sanitizes, and validates HTTP…
permissive · top 15,000 on PyPI
vcrpyVCR.py records HTTP interactions during test…
permissive · top 1,000 on PyPI
pytest-httpbinProvides a pytest fixture that runs a local…
permissive · top 15,000 on PyPI
pytest-loggerPytest-logger is a pytest plugin that…
permissive · top 15,000 on PyPI
pytest-responsesAutomatically mocks HTTP requests across your…
permissive · top 15,000 on PyPI
pytest-mockProvides a pytest fixture that wraps the mock…
permissive · top 1,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