API¶
cassette module¶
-
cassette.
eject
(exc_type=None, exc_value=None, tb=None)[source]¶ Remove cassette, unpatching HTTP requests.
cassette_library module¶
-
class
cassette.cassette_library.
CassetteLibrary
(filename, encoder, config=None)[source]¶ The CassetteLibrary holds the stored requests and manage them.
This is an abstract class that needs to have several methods implemented. In addition, subclasses must store request/response pairs as a keys and values as a dictionary in the property self.data
Parameters: - filename (str) – filename to use when storing and replaying requests.
- encoder (Encoder) – the instantiated encodeder to use
-
add_response
(cassette_name, response)[source]¶ Add a new response to the mocked response.
Parameters: - cassette_name (str) –
- response –
-
cassette_name_for_httplib_connection
(host, port, method, url, body, headers)[source]¶ Create a cassette name from an httplib request.
-
classmethod
create_new_cassette_library
(path, file_format, config=None)[source]¶ Return an instantiated CassetteLibrary.
Use this method to create new a CassetteLibrary. It will automatically determine if it should use a file or directory to back the cassette based on the filename. The method assumes that all file names with an extension (e.g.
/file.json
) are files, and all file names without extensions are directories (e.g./requests
).Parameters: - path (str) – filename of file or directory for storing requests
- file_format (str) – the file_format to use for storing requests
- config (dict) – configuration
-
class
cassette.cassette_library.
CassetteName
[source]¶ A CassetteName represents an unique way to retrieve the cassette from the library.
-
class
cassette.cassette_library.
DirectoryCassetteLibrary
(*args, **kwargs)[source]¶ A CassetteLibrary that stores and manages requests with directory.