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

Add Logging

This helps to figure out which matcher has decided your two cassettes
differ, and figure out when your cassettes have hit the network.

Closes #34
This commit is contained in:
Kevin McCarthy
2014-04-27 11:29:06 -10:00
parent 4302d7753e
commit f317800cb7
4 changed files with 73 additions and 3 deletions

View File

@@ -1,3 +1,6 @@
import logging
log = logging.getLogger(__name__)
def method(r1, r2):
return r1.method == r2.method
@@ -22,5 +25,12 @@ def headers(r1, r2):
return r1.headers == r2.headers
def _log_matches(matches):
differences = [m for m in matches if not m[0]]
if differences:
log.debug('Requests differ according to the following matchers: {0}'.format(differences))
def requests_match(r1, r2, matchers):
return all(m(r1, r2) for m in matchers)
matches = [(m(r1, r2), m) for m in matchers]
_log_matches(matches)
return all([m[0] for m in matches])