Cassette stores and replays HTTP requests.
Project description
Cassette stores and replays HTTP requests made in your Python app.
import urllib2
import cassette
with cassette.play("data/responses.yaml"):
# If the request is not already stored in responses.yaml, cassette
# will request the URL and store its response in the file.
r = urllib2.urlopen("http://www.internic.net/domain/named.root")
# This time, the request response must be in the file. The external
# request is not made. cassette retrieves the response from the
# file.
r = urllib2.urlopen("http://www.internic.net/domain/named.root")
assert "A.ROOT-SERVERS.NET" in r.read(10000)
Cassette also supports the requests library.
import requests
with cassette.play("data/responses.yaml"):
r = requests.get("http://www.internic.net/domain/named.root")
Note that requests stored between different libraries may not be compatible with each other. That is, a request stored with urllib2 might still trigger an external request is the same URL is requested with requests.
Installation
$ pip install cassette
Documentation
Latest documentation: cassette.readthedocs.org
License
cassette is available under the MIT License.
Copyright Uber 2013, Charles-Axel Dein <charles@uber.com>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
cassette-0.3.8.zip
(25.4 kB
view details)
File details
Details for the file cassette-0.3.8.zip
.
File metadata
- Download URL: cassette-0.3.8.zip
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe09b7223ef14f93f1d58be51e959bf99df3422e7fb15aaa36fcd834b68bbade |
|
MD5 | a75b59af3a023bb31998ad4947c75492 |
|
BLAKE2b-256 | afd9a05e70aac583b9bbe4c31e9af20f9c100b08a92b4b15b2fee7efeba8dbf7 |