Created
February 8, 2016 13:50
-
-
Save Sjord/06bede5fb2702b360413 to your computer and use it in GitHub Desktop.
This file contains 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
import vcr | |
import urllib2 | |
import os | |
yaml_file = 'reproduce.yaml' | |
# Begin with existing YAML file with non-matching requests. | |
try: | |
os.remove(yaml_file) | |
except OSError: | |
pass | |
with vcr.use_cassette(yaml_file): | |
urllib2.urlopen('https://github.com/kevin1024/vcrpy').read() | |
# Request same URL several times. | |
with vcr.use_cassette(yaml_file, record_mode='new_episodes'): | |
for i in range(10): | |
response = urllib2.urlopen('https://httpbin.org/bytes/4').read() | |
print response.encode('hex') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment