Last active
November 24, 2023 12:55
-
-
Save lapointexavier/73e93bbfd3ba05738353bb257d3a09e1 to your computer and use it in GitHub Desktop.
Snippet to read a vcr cassette binary body
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 json | |
import gzip | |
import base64 | |
import StringIO | |
from vcr.serialize import deserialize | |
from vcr.serializers import yamlserializer | |
path = '../cassettes/api-InstagramAPITestCase-test_media.yml' | |
with open(path, 'r') as fh: | |
deserialized = deserialize(fh.read(), yamlserializer) | |
body_string = deserialized[1][0]['body']['string'] | |
stio = StringIO.StringIO(body_string) | |
fio = gzip.GzipFile(fileobj=stio) | |
print(json.load(fio)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A ruby version to achieve the same: