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

test cassette library dir

This commit is contained in:
Kevin McCarthy
2013-08-19 19:47:54 -10:00
parent 28379e9000
commit b688dd362d
2 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,4 @@
import os
import json
import urllib2
import vcr
@@ -12,3 +13,20 @@ def test_set_serializer_default_config(tmpdir):
with open(str(tmpdir.join('test.json'))) as f:
assert json.loads(f.read())
def test_default_set_cassette_library_dir(tmpdir):
my_vcr = vcr.VCR(cassette_library_dir=str(tmpdir.join('subdir')))
with my_vcr.use_cassette('test.json'):
urllib2.urlopen('http://httpbin.org/get')
assert os.path.exists(str(tmpdir.join('subdir').join('test.json')))
def test_override_set_cassette_library_dir(tmpdir):
my_vcr = vcr.VCR(cassette_library_dir=str(tmpdir.join('subdir')))
with my_vcr.use_cassette('test.json', cassette_library_dir=str(tmpdir.join('subdir2'))):
urllib2.urlopen('http://httpbin.org/get')
assert os.path.exists(str(tmpdir.join('subdir2').join('test.json')))
assert not os.path.exists(str(tmpdir.join('subdir').join('test.json')))