mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-08 16:53:23 +00:00
Added integration test for match on 'method'
This commit is contained in:
24
tests/integration/test_matchers.py
Normal file
24
tests/integration/test_matchers.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import vcr
|
||||||
|
import pytest
|
||||||
|
from six.moves.urllib.request import urlopen
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def cassette(tmpdir):
|
||||||
|
return str(tmpdir.join('test.yml'))
|
||||||
|
|
||||||
|
|
||||||
|
def test_method_matcher(cassette):
|
||||||
|
# prepare cassete
|
||||||
|
with vcr.use_cassette(cassette, match_on=['method']) as cass:
|
||||||
|
urlopen('http://httpbin.org/')
|
||||||
|
assert len(cass) == 1
|
||||||
|
|
||||||
|
# play cassette with matching on method
|
||||||
|
with vcr.use_cassette(cassette, match_on=['method']) as cass:
|
||||||
|
urlopen('http://httpbin.org/get')
|
||||||
|
assert cass.play_count == 1
|
||||||
|
|
||||||
|
with pytest.raises(vcr.errors.CannotOverwriteExistingCassetteException):
|
||||||
|
with vcr.use_cassette(cassette, match_on=['method']) as cass:
|
||||||
|
urlopen('http://httpbin.org/post', data='')
|
||||||
Reference in New Issue
Block a user