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

Add support for custom request matchers

This commit not only changes the default method of matching requests
(just match on method and URI instead of the entire request + headers)
but also allows the user to add custom matchers.
This commit is contained in:
Kevin McCarthy
2013-09-16 20:09:25 -10:00
parent 03c22d79dd
commit a66f462dcd
7 changed files with 184 additions and 10 deletions

26
vcr/matchers.py Normal file
View File

@@ -0,0 +1,26 @@
def method(r1, r2):
return r1.method == r2.method
def url(r1, r2):
return r1.url == r2.url
def host(r1, r2):
return r1.host == r2.host
def path(r1, r2):
return r1.path == r2.path
def body(r1, r2):
return r1.body == r2.body
def headers(r1, r2):
return r1.headers == r2.headers
def requests_match(r1, r2, matchers):
return all(m(r1, r2) for m in matchers)