skip to navigation
skip to content

Not Logged In

cassette 0.3.4

Cassette stores and replays HTTP requests made in your Python app.

Latest Version: 0.3.8

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 <https://github.com/kennethreitz/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>

 
File Type Py Version Uploaded on Size
cassette-0.3.4.zip (md5) Source 2014-08-27 22KB
  • Downloads (All Versions):
  • 99 downloads in the last day
  • 577 downloads in the last week
  • 2358 downloads in the last month