Registry / testing / betamax

betamax

JSON →
library0.9.0pypypi✓ verified 85d ago

A VCR imitation for python-requests that records HTTP interactions and replays them during tests. Current version 0.9.0; release cadence is low (last release 2023).

pip install betamax
INSTALL
IMPORT
SIG · BETAMAX
B
betamax
testingpythonv0.9.0
Install
2.1s avg
Import
702ms
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.760s · 21.3MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.1s · import 0.644s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Betamax
from betamax import Betamax
from betamax import BetamaxSession
BetamaxSession does not exist; the correct class is Betamax.
recorder
with Betamax(session) as recorder:
recorder = Betamax(session); recorder.start()
Do not manually start/stop; use as context manager.

Record and replay HTTP requests using Betamax with a requests.Session.

import requests from betamax import Betamax session = requests.Session() recorder = Betamax(session) with recorder.use_cassette('example'): response = session.get('https://httpbin.org/get') print(response.status_code)
Debug
Known issues
deprecatedpython-requests < 2.0 are not supported. Betamax requires requests 2.x.
fix
Upgrade requests to >=2.0.
affects: <0.9.0
gotchaCassette files are stored in a 'cassettes/' directory by default. Forgetting to create this directory or adjust the path can cause FileNotFoundError.
fix
Ensure the cassettes directory exists or set a custom cassette_library_dir.
affects: all
gotchaBetamax does not match requests purely by URL; it uses request method, URI, and (optionally) headers/body. Mismatches lead to cassette playback failures.
fix
Configure matchers via Betamax(matchers=...) or use default Matchers.
affects: all
Errors
Common errors & fixes
FileNotFoundError: [Errno 2] No such file or directory: 'cassettes/example.json'
Default cassette_library_dir is 'cassettes/' and it does not exist.
fix
Create a 'cassettes' folder in your working directory, or set cassette_library_dir to an existing path.
No cassette found for request: GET http://httpbin.org/get
The request being made does not match any recorded cassette; maybe headers or body differ.
fix
Ensure that the request (method, URI, headers, body) exactly matches the recorded interaction. Or use 'record_mode' to allow recording.
Upgrade
Version history
0.9.0latest on PyPI · released Feb 8, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
betamax — pip install betamax · libregistry