kevin1024

vcrpy: Replay HTTP Interactions in Tests

VCR.py records HTTP interactions to cassette files and replays matching responses in later test runs. It helps Python developers make network-dependent tests faster, deterministic, and usable offline after recording.

View on GitHub Compare
Stars
3k
Forks
444
Stars, last 29 days
+4

Our take

Health score

49/100

How it is scored
Activity
38
Community
89
Issues
47
Pull requests
21

+4 stars in the last 29 days

  • More contributors than 78% of the projects we track

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

3,022

Forks

448

Change since Nov 4, 2026: 0 stars·+2 forks

Overview

VCR.py is a Python library for recording HTTP requests and responses during tests, then replaying them from cassette files on later runs. This avoids repeated network traffic and makes tests that depend on HTTP services faster and more predictable.

It suits teams testing code that makes HTTP requests through libraries supported by VCR.py. The first run needs to reach the service to record interactions; subsequent runs can use the saved cassette data instead.

Key Features

  • Records HTTP interactions made within a VCR.py context or decorated function.
  • Serializes interactions to cassette files, using YAML by default.
  • Intercepts requests that match recorded interactions and returns their saved responses.
  • Lets tests run without HTTP traffic after interactions have been recorded.
  • Supports refreshing recorded data by removing cassette files and running the tests again.
  • Can be used with pytest through the separate pytest-recording library.

Use Cases

  • Python developers can test HTTP client code without contacting remote services on every test run.
  • Teams can make tests that depend on external APIs more deterministic when the recorded interactions remain suitable.
  • Developers can run tests offline after recording the required interactions.
  • Maintainers can update test fixtures after an API changes by recording a new set of interactions.

Getting Started

Read the repository README and documentation for setup and usage details. For pytest fixtures, see pytest-recording.

Alternatives

  • python-mocket: Mocket intercepts socket and SSL traffic for configurable mocks, while vcrpy records HTTP exchanges to cassettes for later replay.
  • responses: Responses mocks Python Requests calls with registered responses and assertions, rather than recording and replaying cassette files.
  • httmock: httmock replaces matching requests calls with configured responses, rather than recording live interactions for cassette replay.
  • HTTPretty: HTTPretty intercepts HTTP traffic at the socket level and can capture or replay it, while vcrpy uses cassette-based recording and matching.
ProjectLanguageLicenseStarsStatus
vcrpyPythonMIT3kNot checked yet
python-mocketPythonBSD-3-Clause311Active
responsesPythonApache-2.04.3kActive
httmockPython–471Inactive
HTTPrettyPythonMIT2.1kInactive

Considerations

  • The initial recording run makes real HTTP requests, so the service must be reachable and the test environment must be able to access it.
  • Replay depends on requests matching interactions stored in cassette files. Changes to an API or to the requests made by the test may require re-recording.
  • VCR.py records traffic through the libraries it supports; check the documentation for details about compatibility and configuration.

Found this useful?

Share it with someone who would like vcrpy.

Comparisons