1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-08 16:53:23 +00:00

Removed frozenset

This commit is contained in:
Max Shytikov
2014-04-29 23:59:25 +02:00
parent 7e677f516d
commit e4d1db0617
2 changed files with 4 additions and 13 deletions

View File

@@ -7,13 +7,10 @@ class Request(object):
self.method = method
self.uri = uri
self.body = body
# make headers a frozenset so it will be hashable
self.headers = frozenset(headers.items())
self.headers = headers
def add_header(self, key, value):
tmp = dict(self.headers)
tmp[key] = value
self.headers = frozenset(tmp.iteritems())
self.headers[key] = value
@property
def scheme(self):

View File

@@ -6,12 +6,6 @@ except ImportError:
import json
def _json_default(obj):
if isinstance(obj, frozenset):
return dict(obj)
return obj
def deserialize(cassette_string):
data = json.loads(cassette_string)
requests = [Request._from_dict(r['request']) for r in data]
@@ -28,8 +22,8 @@ def serialize(cassette_dict):
cassette_dict['responses']
)])
try:
return json.dumps(data, indent=4, default=_json_default)
except UnicodeDecodeError as e:
return json.dumps(data, indent=4)
except UnicodeDecodeError:
raise UnicodeDecodeError(
"Error serializing cassette to JSON. ",
"Does this HTTP interaction contain binary data? ",