Last active
January 13, 2020 01:08
-
-
Save jarhill0/72dd9e43d29f2b47d846edc263a0a7f2 to your computer and use it in GitHub Desktop.
Demonstrating use of new cassette load/eject hooks in Betamax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from betamax import Betamax | |
from requests import Session | |
def before(cassette): print('cassette created.') | |
def after(cassette): print('cassette destroyed') | |
session = Session() | |
recorder = Betamax(session, cassette_library_dir='test cassettes') | |
with recorder.configure() as config: | |
config.after_start(callback=before) | |
config.before_stop(callback=after) | |
with recorder.use_cassette('My test cassette'): | |
print('in with block') | |
print(session.get('https://github.com')) | |
print('about to exit with block') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cassette created. | |
in with block | |
<Response [200]> | |
about to exit with block | |
cassette destroyed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment