CheckOps
VCR.py
VCR.py is an MIT-licensed Python library, ported from Ruby's VCR, that records HTTP interactions to cassette files and replays them in later test runs for fast, deterministic, offline tests.
- Unit Testing
- Python
- Open source
- Free
- Mocking
- API mocking
- Library
- Unit testing
- Integration testing
- API & contract testing
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
Introduction
VCR.py is a Python version of Ruby’s VCR library. The first time code runs inside a VCR.py context manager or decorated function, it records all HTTP interactions through supported libraries and writes them to a flat file, a cassette, in YAML by default. On later runs it reads the cassette and returns the recorded responses for matching requests, so no real HTTP traffic occurs. The README lists the benefits: working offline, completely deterministic tests and faster execution.
Record modes control behaviour: once records only when the cassette is missing, new_episodes adds new interactions, none forbids recording (ideal in CI) and all always re-records. Request matching can be tuned (method, URI, body, headers), and filters remove secrets such as authorisation headers and query tokens before cassettes are saved. VCR.py works with popular HTTP clients, including requests, urllib3, httpx and aiohttp, and the pytest-recording plugin integrates it with pytest via a @pytest.mark.vcr marker. Version 9.4.2 was released on 2 November 2026.
The source code is at kevin1024/vcrpy on GitHub under the MIT licence, with about 3,000 stars; the most recent commit was on 10 November 2026.
Features
- Record and replay: Real responses captured once, replayed forever.
- Record modes: once, new_episodes, none and all.
- Secret filtering: Strip headers, query parameters and body data.
- Many clients: requests, urllib3, httpx, aiohttp and more.
Pros
- Free to use: Open source under the MIT licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 10 November 2026.
- Community: About 3,000 GitHub stars.
Cons
- Stale cassettes: Recorded responses drift from the real API over time; re-record regularly.
- Secrets risk: Forgetting filters can commit credentials to the repository.
Usage and Links (Example)
import requests
import vcr
my_vcr = vcr.VCR(
cassette_library_dir="tests/cassettes",
record_mode="once",
filter_headers=["authorization"],
)
@my_vcr.use_cassette("github_user.yaml")
def test_github_user():
r = requests.get("https://api.github.com/users/octocat")
assert r.json()["login"] == "octocat"
In CI, set record_mode="none" so tests fail rather than hitting the network.
Resources:
Pricing
VCR.py is free and open source under the MIT licence.
Recommended for?
- Python code calling third-party APIs that should be tested offline.
- Teams wanting realistic responses without hand-writing stubs.
Conclusion
VCR.py makes HTTP-heavy Python tests fast and deterministic by recording real interactions, provided cassettes are filtered and refreshed.
Alternatives
Other tools on CheckOps that cover similar ground. Open a page, or compare one with VCR.py side by side.
Rresponsesresponses is an Apache-2.0 Python library from Sentry for mocking the Requests HTTP library, letting tests register fake responses, match request details and assert on calls.Compare with VCR.py
VVCR (Ruby)VCR is a Ruby library that records your test suite's HTTP interactions to cassettes and replays them in future runs for fast, deterministic, accurate tests; it uses the Hippocratic License 2.1.Compare with VCR.py- Ppytestpytest is the usual Python test runner: plain asserts, fixtures, parametrization, and a large plugin set.Compare with VCR.py
WWireMockA tool for mocking HTTP services.Compare with VCR.py
HHoverflyLightweight service virtualization/ API simulation / API mocking tool for developers and testers.Compare with VCR.py
MMock Service Worker (MSW)Mock Service Worker (MSW) is an MIT-licensed API mocking library that intercepts network requests at the network level in browsers (via a Service Worker) and Node.js, for REST, GraphQL and WebSocket APIs.Compare with VCR.py