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

better logging on cassettenotfound

This commit is contained in:
Ivan Malison
2015-10-25 21:04:59 -07:00
parent f6b8e4f8e7
commit 8a5bf23d34
3 changed files with 75 additions and 5 deletions

View File

@@ -227,12 +227,26 @@ class VCRConnection(object):
if self.cassette.write_protected and self.cassette.filter_request(
self._vcr_request
):
most_similar_request = None
failing_matchers = None
most_similar_request_info = None
try:
most_similar_request_info = self.cassette.similar_requests(self._vcr_request)
most_similar_request = most_similar_request_info[0][0]
failing_matchers = self.cassette.failing_matchers(
self._vcr_request, most_similar_request
)
except Exception as err:
print "XXXX {0}".format(err)
import ipdb; ipdb.set_trace()
raise CannotOverwriteExistingCassetteException(
"No match for the request (%r) was found. "
"Can't overwrite existing cassette (%r) in "
"your current record mode (%r)."
"your current record mode (%r). Most similar request was (%r). "
"It differed from the request according to (%r). \n\n\n(%r)"
% (self._vcr_request, self.cassette._path,
self.cassette.record_mode)
self.cassette.record_mode, most_similar_request,
failing_matchers, most_similar_request_info)
)
# Otherwise, we should send the request, then get the response