V
VCR for Python
Automatically mock your HTTP interactions to simplify and speed up testing
VCR for Python (vcrpy) is a highly popular unit-testing library designed to simplify network interaction testing. It intercepts and records outgoing HTTP requests from test runs to local YAML files (‘cassettes’), which are then replayed during subsequent runs to speed up execution.
Key Features of VCR for Python
- Automated Cassette Recording: Records network requests and responses on the initial test run to local YAML files.
- Fast YAML Playback: Replays matching network calls locally, eliminating external network requests on subsequent runs.
- Request Matching Rules: Customize request matching by URI, headers, request body, query parameters, or host.
- Sensitive Data Scrubbing: Built-in filter functions to remove API tokens, passwords, and PII from YAML cassettes.
Benefits of Using VCR for Python
- Accelerate Test Runs: Running tests against local YAML files is up to 100x faster than calling real remote servers.
- Deterministic Testing: Prevents test suite failures caused by third-party downtime, rate limits, or network glitches.
- Offline Capabilities: Run your entire integration and API test suites on airplanes or without an active internet link.
To ensure fast, offline, and reliable API verification, VCR for Python allows QA engineers to capture real HTTP requests on the first test run and mock them automatically in subsequent test runs.
Tags:
HTTPTestingRecord & ReplayPythonMocking


