1
0
mirror of https://github.com/kevin1024/vcrpy.git synced 2025-12-09 09:13:23 +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

View File

@@ -1,5 +1,6 @@
import pytest
import yaml
import mock
from vcr.cassette import Cassette
@@ -46,18 +47,24 @@ def test_cassette_len():
assert len(a) == 2
def _mock_requests_match(request1, request2, matchers):
return request1 == request2
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
def test_cassette_contains():
a = Cassette('test')
a.append('foo', 'bar')
assert 'foo' in a
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
def test_cassette_response_of():
a = Cassette('test')
a.append('foo', 'bar')
assert a.response_of('foo') == 'bar'
@mock.patch('vcr.cassette.requests_match', _mock_requests_match)
def test_cassette_get_missing_response():
a = Cassette('test')
with pytest.raises(KeyError):