Skip to content

Instantly share code, notes, and snippets.

@svdgraaf
Created October 1, 2019 14:23
Show Gist options
  • Save svdgraaf/7f56596fb9f3bfddd599ef9966b5f775 to your computer and use it in GitHub Desktop.
Save svdgraaf/7f56596fb9f3bfddd599ef9966b5f775 to your computer and use it in GitHub Desktop.
vcrpy example
import os
import requests
import unittest
import vcr
dir_path = os.path.dirname(os.path.realpath(__file__))
dd_vcr = vcr.VCR(
cassette_library_dir="%s/cassettes" % dir_path,
path_transformer=vcr.VCR.ensure_suffix(".yml"),
record_mode="once",
filter_headers=[
("authorization", "XXXXXX"),
("X-Amz-Security-Token", "XXXXXX"),
("X-Amz-Date", "XXXXXX"),
("X-Amz-Target", "XXXXXX"),
],
match_on=['method', 'scheme', 'host', 'port', 'path', 'query'],
)
class FoobarTest(unittest.TestCase):
@dd_vcr.use_cassette
def test_foobar(self):
results = requests.get("https://downdetector.com/")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment