1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 17:15:35 +00:00

update serializers

This commit is contained in:
Kevin McCarthy
2014-05-06 19:20:42 -10:00
parent 2c33ae2664
commit b43c63f284
5 changed files with 24 additions and 24 deletions

View File

@@ -1,30 +1,12 @@
import tempfile
from .persisters.filesystem import FilesystemPersister
from .serialize import serialize, deserialize
def _check_for_old_cassette(cassette_content):
# crate tmp with cassete content and try to migrate it
with tempfile.NamedTemporaryFile(mode='w+') as f:
f.write(cassette_content)
f.seek(0)
if migration.try_migrate(f.name):
raise ValueError(
"Your cassette files were generated in an older version "
"of VCR. Delete your cassettes or run the migration script."
"See http://git.io/mHhLBg for more details."
)
def load_cassette(cassette_path, serializer):
with open(cassette_path) as f:
cassette_content = f.read()
try:
cassette = deserialize(cassette_content, serializer)
except TypeError:
_check_for_old_cassette(cassette_content)
raise
cassette = deserialize(cassette_content, serializer)
return cassette