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

Add ability to add custom patches to vcr and cassettes.

This commit is contained in:
Ivan Malison
2015-01-08 10:53:44 -08:00
parent 83aed99058
commit c0a22df7ed
5 changed files with 63 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import pytest
from vcr import VCR, use_cassette
from vcr.request import Request
from vcr.stubs import VCRHTTPSConnection
def test_vcr_use_cassette():
@@ -74,3 +75,18 @@ def test_fixtures_with_use_cassette(random_fixture):
# fixtures. It is admittedly a bit strange because the test would never even
# run if the relevant feature were broken.
pass
def test_custom_patchers():
class Test(object):
attribute = None
attribute2 = None
test_vcr = VCR(custom_patches=((Test, 'attribute', VCRHTTPSConnection),))
with test_vcr.use_cassette('custom_patches'):
assert issubclass(Test.attribute, VCRHTTPSConnection)
assert VCRHTTPSConnection is not Test.attribute
with test_vcr.use_cassette('custom_patches', custom_patches=((Test, 'attribute2', VCRHTTPSConnection),)):
assert issubclass(Test.attribute, VCRHTTPSConnection)
assert VCRHTTPSConnection is not Test.attribute
assert Test.attribute is Test.attribute2