mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 01:03:24 +00:00
test: add tests to drop_unused_requests option
This commit is contained in:
@@ -5,6 +5,7 @@ from urllib.request import urlopen
|
||||
import pytest
|
||||
|
||||
import vcr
|
||||
from vcr.cassette import Cassette
|
||||
|
||||
|
||||
def test_set_serializer_default_config(tmpdir, httpbin):
|
||||
@@ -80,3 +81,20 @@ def test_dont_record_on_exception(tmpdir):
|
||||
assert b"Not in content" in urlopen("http://httpbin.org/get").read()
|
||||
|
||||
assert not os.path.exists(str(tmpdir.join("dontsave2.yml")))
|
||||
|
||||
def test_set_drop_unused_requests(tmpdir, httpbin):
|
||||
my_vcr = vcr.VCR(drop_unused_requests=True)
|
||||
file = str(tmpdir.join("test.yaml"))
|
||||
|
||||
with my_vcr.use_cassette(file):
|
||||
urlopen(httpbin.url)
|
||||
urlopen(httpbin.url + "/get")
|
||||
|
||||
cassette = Cassette.load(path=file)
|
||||
assert len(cassette) == 2
|
||||
|
||||
with my_vcr.use_cassette(file):
|
||||
urlopen(httpbin.url)
|
||||
|
||||
cassette = Cassette.load(path=file)
|
||||
assert len(cassette) == 1
|
||||
|
||||
Reference in New Issue
Block a user