]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
update tests
authorKevin McCarthy <me@kevinmccarthy.org>
Sun, 11 Aug 2013 02:18:27 +0000 (16:18 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Mon, 12 Aug 2013 01:05:41 +0000 (15:05 -1000)
tests/integration/test_basic.py

index 3c178a871a0c6e88c8cfd497702203af87646aed..5b26de70f08e2da26fa91e4114cd207af803553d 100644 (file)
@@ -1,34 +1,32 @@
 '''Basic tests about cassettes'''
 # coding=utf-8
 
-# Internal imports
-import vcr
-from .common import TestVCR
-
 # External imports
 import os
 import urllib2
 
+# Internal imports
+import vcr
 
-class TestCassette(TestVCR):
-    '''We should be able to save a cassette'''
-    fixtures = os.path.join('tests', 'fixtures', 'basic')
+def test_nonexistent_directory(tmpdir):
+    '''If we load a cassette in a nonexistent directory, it can save ok'''
+    # Check to make sure directory doesnt exist
+    assert not os.path.exists(str(tmpdir.join('nonexistent')))
 
-    def test_nonexistent_directory(self):
-        '''If we load a cassette in a nonexistent directory, it can save ok'''
-        self.assertFalse(os.path.exists(self.fixture('nonexistent')))
-        with vcr.use_cassette(self.fixture('nonexistent', 'cass.yaml')):
-            urllib2.urlopen('http://httpbin.org/').read()
-        # This should have made the file and the directory
-        self.assertTrue(
-            os.path.exists(self.fixture('nonexistent', 'cass.yaml')))
+    # Run VCR to create dir and cassette file
+    with vcr.use_cassette(str(tmpdir.join('nonexistent','cassette.yml'))):
+        urllib2.urlopen('http://httpbin.org/').read()
 
-    def test_unpatch(self):
-        '''Ensure that our cassette gets unpatched when we're done'''
-        with vcr.use_cassette(self.fixture('unpatch.yaml')) as cass:
-            urllib2.urlopen('http://httpbin.org/').read()
+    # This should have made the file and the directory
+    assert os.path.exists(str(tmpdir.join('nonexistent','cassette.yml')))
 
-        # Make the same requests, and assert that we haven't served any more
-        # requests out of cache
+def test_unpatch(tmpdir):
+    '''Ensure that our cassette gets unpatched when we're done'''
+    with vcr.use_cassette(str(tmpdir.join('unpatch.yaml'))) as cass:
         urllib2.urlopen('http://httpbin.org/').read()
-        self.assertEqual(cass.play_count, 0)
+
+    # Make the same request, and assert that we haven't served any more
+    # requests out of cache
+    urllib2.urlopen('http://httpbin.org/').read()
+    assert cass.play_count == 0
+