]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
test cassette library dir
authorKevin McCarthy <me@kevinmccarthy.org>
Tue, 20 Aug 2013 05:47:54 +0000 (19:47 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Tue, 20 Aug 2013 05:49:06 +0000 (19:49 -1000)
tests/integration/test_config.py
vcr/config.py

index 6dcfe40dbeb8d044bfbc97bde198cf6537b1ec7e..11f1bede79e370e9926c7a3af39eec709c0ba36c 100644 (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')))
+
index 88ac41f22f1aa9bd8ae700ccfe1351ce19a2423c..4c70d2d3bde2bc85a1581221d7033540ac648db3 100644 (file)
@@ -1,3 +1,4 @@
+import os
 from .cassette import Cassette
 from .serializers.yamlserializer import YamlSerializer
 from .serializers.jsonserializer import JSONSerializer