]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
headers
authorKevin McCarthy <me@kevinmccarthy.org>
Thu, 31 May 2012 07:52:01 +0000 (21:52 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Thu, 31 May 2012 07:52:01 +0000 (21:52 -1000)
test.py

diff --git a/test.py b/test.py
index 14ef47c7326c67e2d617cc894db22ba56658de74..76d8f0cce73936474b7a7c59d73779494ff36971 100644 (file)
--- a/test.py
+++ b/test.py
@@ -15,14 +15,22 @@ class TestHttpRequest(unittest.TestCase):
             pass
 
     def test_response_code(self):
+        code = urllib2.urlopen('http://www.iana.org/domains/example/').getcode()
         with vcr.use_cassette(TEST_CASSETTE_FILE):
-            code = urllib2.urlopen('http://www.iana.org/domains/example/').getcode()
+            self.assertEqual(code, urllib2.urlopen('http://www.iana.org/domains/example/').getcode())
             self.assertEqual(code, urllib2.urlopen('http://www.iana.org/domains/example/').getcode())
 
     def test_response_body(self):
+        body = urllib2.urlopen('http://www.iana.org/domains/example/').read()
         with vcr.use_cassette('test/synopsis.yaml'):
-            body = urllib2.urlopen('http://www.iana.org/domains/example/').read()
             self.assertEqual(body, urllib2.urlopen('http://www.iana.org/domains/example/').read())
+            self.assertEqual(body, urllib2.urlopen('http://www.iana.org/domains/example/').read())
+
+    def test_response_headers(self):
+        headers = urllib2.urlopen('http://www.iana.org/domains/example/').info()
+        with vcr.use_cassette('test/synopsis.yaml'):
+            self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info())
+            self.assertEqual(headers, urllib2.urlopen('http://www.iana.org/domains/example/').info())
 
 
 if __name__ == '__main__':