Overview of VCR.py
masterVCR.py is a Python library designed to simplify and speed up tests that make HTTP requests. It works by recording HTTP interactions (requests and responses) the first time a test is run and serializing them into a flat file called a 'cassette' (defaulting to YAML format).
On subsequent test runs, VCR.py intercepts matching HTTP requests and returns the recorded responses from the cassette instead of making actual network traffic. This provides:
- Offline capability: Run tests without an internet connection.
- Determinism: Tests are completely deterministic because they use recorded data.
- Speed: Test execution is significantly faster as it avoids network latency.
To update cassettes if an API changes, simply delete the existing cassette files and re-run your tests to record the new interactions.