pytest-recording
pytest-recording is a pytest plugin that records and replays HTTP traffic during testing using VCR.py. It allows tests to run against pre-recorded cassettes, reducing dependency on external services and speeding up test execution.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | kiwicom/pytest-recording |
| Owner | kiwicom |
| Primary language | Python |
| License | MIT — OSI-approved |
| Stars | 612 |
| Forks | 49 |
| Open issues | 40 |
| Latest release | v0.13.4 (2025-05-08) |
| Last updated | 2026-06-18 |
| Source | https://github.com/kiwicom/pytest-recording |
What pytest-recording is
A Python pytest plugin wrapper around VCR.py that provides decorators (@pytest.mark.vcr) for recording/replaying HTTP interactions, with support for multiple cassettes, network blocking, custom matchers, and configurable record modes (once, none, rewrite, all).
Get the pytest-recording source
Clone the repository and explore it locally.
git clone https://github.com/kiwicom/pytest-recording.gitcd pytest-recording# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Cassette files must be committed to version control or regenerated in CI; decide on storage strategy and file naming conventions upfront.
- Sensitive data (API keys, auth tokens, PII) must be filtered via vcr_config (filter_headers, filter_query_parameters) to prevent leaking secrets into cassettes.
- Record mode defaults to 'none' (no network access); tests fail silently if cassettes are missing—require explicit --record-mode flag to regenerate.
- Multiple cassettes can be combined via decorators; merging order and conflict resolution behavior should be documented per test suite.
- Custom VCR matchers (via pytest_recording_configure hook) may be needed if default request matching (URL/method) is insufficient.
When to avoid it — and what to weigh
- Need Real-Time API Behavior Testing — If tests must validate live API state changes (e.g., payment processing, real-time data feeds), cassettes will return stale recordings and mask real failures.
- Testing Highly Dynamic or Protocol-Specific Services — VCR.py works with HTTP/HTTPS. Incompatible with WebSocket, gRPC, or binary protocols. Cassettes are brittle if request/response structure changes frequently.
- Require Minimal Overhead in Test Setup — Cassette management adds complexity: maintaining cassette files, handling media encoding, managing sensitive data filtering. Adds file I/O on every test run.
- Conflict with pytest-vcr — Plugin is explicitly incompatible with pytest-vcr. Teams already using pytest-vcr must migrate, which may require refactoring test decorators.
License & commercial use
MIT License. Permissive OSI-approved license allows unrestricted use, modification, and distribution in commercial and proprietary contexts, subject only to retention of copyright and license notice.
MIT License explicitly permits commercial use without restriction. No vendor lock-in, no commercial terms beyond attribution. Safe for production test infrastructure in proprietary codebases.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Cassettes record full HTTP requests/responses; sensitive data (credentials, tokens, PII) must be explicitly filtered via filter_headers and filter_query_parameters to prevent accidental secrets in version control. Default behavior does NOT redact sensitive data automatically. Network blocking feature supports allowed_hosts allowlisting to prevent unintended outbound requests during test runs.
Alternatives to consider
pytest-httpserver / responses
Manually mock HTTP endpoints instead of recording. Provides more explicit control but requires handwritten response stubs; does not capture real API behavior.
unittest.mock + fixture data
Pure mocking without VCR. Lighter weight but brittle if API contracts change; does not encourage recording real behavior.
Live API tests + feature flags
Run against real APIs in staging with feature flags to isolate tests. Requires staging environment and network access; slower but captures live behavior.
Build on pytest-recording with DEV.co software developers
Replace flaky external API calls with deterministic cassettes. pytest-recording captures real behavior once, replays it forever. Faster CI, zero network dependency.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
pytest-recording FAQ
How do I prevent secrets (API keys) from being recorded in cassettes?
What happens if a cassette file is missing when I run tests?
Can I use pytest-recording with pytest-vcr?
How do I ensure cassettes are reproducible across CI and local development?
Custom software development services
From first prototype to production, DEV.co delivers software development services around tools like pytest-recording. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.
Stabilize Your API Tests
Replace flaky external API calls with deterministic cassettes. pytest-recording captures real behavior once, replays it forever. Faster CI, zero network dependency.