← ClaudeAtlas

pytest-recordinglisted

Work with pytest-recording (VCR.py) for recording and replaying HTTP interactions in tests. Use when writing VCR tests, managing cassettes, configuring VCR options, filtering sensitive data, or debugging recorded HTTP responses.
aiskillstore/marketplace · ★ 329 · Testing & QA · score 79
Install: claude install-skill aiskillstore/marketplace
# pytest-recording (VCR.py) Testing ## Overview pytest-recording wraps VCR.py to record HTTP interactions as YAML cassettes, enabling deterministic tests without live API calls. ## Quick Reference ### Running Tests ```bash # Run all tests (uses existing cassettes) uv run pytest tests/ # Run a single test uv run pytest tests/test_module.py::test_function # Rewrite all cassettes with fresh responses uv run pytest tests/ --vcr-record=rewrite # Record only missing cassettes uv run pytest tests/ --vcr-record=new_episodes # Disable VCR (make live requests) uv run pytest tests/ --disable-recording ``` ### Recording Modes | Mode | Flag | Behavior | |------|------|----------| | `none` | `--vcr-record=none` | Only replay, fail if no cassette | | `once` | (default) | Record if no cassette exists | | `new_episodes` | `--vcr-record=new_episodes` | Record new requests, keep existing | | `all` | `--vcr-record=all` | Always record, overwrite existing | | `rewrite` | `--vcr-record=rewrite` | Delete and re-record all cassettes | ### Writing VCR Tests Basic test with VCR: ```python import pytest @pytest.mark.vcr() def test_api_call(): response = my_api_function() assert response.status_code == 200 ``` Custom cassette name: ```python @pytest.mark.vcr("custom_cassette_name.yaml") def test_with_custom_cassette(): pass ``` Multiple cassettes: ```python @pytest.mark.vcr("cassette1.yaml", "cassette2.yaml") def test_with_multiple_cassettes(): pass ``` ### VCR Config