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

formatting fixes

This commit is contained in:
Kevin McCarthy
2013-12-01 14:38:46 -10:00
parent 188b57a2fa
commit 49929e3064
3 changed files with 15 additions and 7 deletions

View File

@@ -78,10 +78,13 @@ class Cassette(object):
def responses_of(self, request): def responses_of(self, request):
''' '''
Find the responses corresponding to a request. Find the responses corresponding to a request.
This function isn't actually used by VCR internally, but is This function isn't actually used by VCR internally, but is
provided as an external API. provided as an external API.
''' '''
responses = [resp for req, resp in self.data if requests_match(req, request, self._match_on)] responses = \
[resp for req, resp in self.data if
requests_match(req, request, self._match_on)]
if responses: if responses:
return responses return responses
# I decided that a KeyError is the best exception to raise # I decided that a KeyError is the best exception to raise

View File

@@ -8,5 +8,5 @@ class FilesystemPersister(object):
dirname, filename = os.path.split(cassette_path) dirname, filename = os.path.split(cassette_path)
if dirname and not os.path.exists(dirname): if dirname and not os.path.exists(dirname):
os.makedirs(dirname) os.makedirs(dirname)
with open(cassette_path, 'w') as f: with open(cassette_path, 'w') as f:
f.write(data) f.write(data)

View File

@@ -165,12 +165,17 @@ class VCRConnectionMixin:
'''Retrieve a the response''' '''Retrieve a the response'''
# Check to see if the cassette has a response for this request. If so, # Check to see if the cassette has a response for this request. If so,
# then return it # then return it
if self._vcr_request in self.cassette and self.cassette.record_mode != "all" and self.cassette.rewound: if self._vcr_request in self.cassette and \
self.cassette.record_mode != "all" and \
self.cassette.rewound:
response = self.cassette.play_response(self._vcr_request) response = self.cassette.play_response(self._vcr_request)
return VCRHTTPResponse(response) return VCRHTTPResponse(response)
else: else:
if self.cassette.write_protected: if self.cassette.write_protected:
raise Exception("Can't overwrite existing cassette in your current record mode.") raise Exception(
"Can't overwrite existing cassette in \
your current record mode."
)
# Otherwise, we should send the request, then get the response # Otherwise, we should send the request, then get the response
# and return it. # and return it.