mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
pep8
This commit is contained in:
@@ -2,8 +2,9 @@ from vcr.serializers import compat
|
||||
from vcr.request import Request
|
||||
import yaml
|
||||
|
||||
#version 1 cassettes started with VCR 1.0.x. Before 1.0.x, there was no versioning.
|
||||
CASSETTE_FORMAT_VERSION = 1
|
||||
# version 1 cassettes started with VCR 1.0.x.
|
||||
# Before 1.0.x, there was no versioning.
|
||||
CASSETTE_FORMAT_VERSION = 1
|
||||
|
||||
"""
|
||||
Just a general note on the serialization philosophy here:
|
||||
@@ -17,9 +18,11 @@ Serializing: bytestring -> string (yaml persists to utf-8)
|
||||
Deserializing: string (yaml converts from utf-8) -> bytestring
|
||||
"""
|
||||
|
||||
|
||||
def _looks_like_an_old_cassette(data):
|
||||
return isinstance(data, list) and len(data) and 'request' in data[0]
|
||||
|
||||
|
||||
def _warn_about_old_cassette_format():
|
||||
raise ValueError(
|
||||
"Your cassette files were generated in an older version "
|
||||
@@ -27,6 +30,7 @@ def _warn_about_old_cassette_format():
|
||||
"See http://git.io/mHhLBg for more details."
|
||||
)
|
||||
|
||||
|
||||
def deserialize(cassette_string, serializer):
|
||||
try:
|
||||
data = serializer.deserialize(cassette_string)
|
||||
@@ -38,7 +42,9 @@ def deserialize(cassette_string, serializer):
|
||||
_warn_about_old_cassette_format()
|
||||
|
||||
requests = [Request._from_dict(r['request']) for r in data['interactions']]
|
||||
responses = [compat.convert_to_bytes(r['response']) for r in data['interactions']]
|
||||
responses = [
|
||||
compat.convert_to_bytes(r['response']) for r in data['interactions']
|
||||
]
|
||||
return requests, responses
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user