Permalink
Browse files

cleanup

  • Loading branch information...
1 parent e1cd92b commit bf844c6952e3dafc6f679c5e096cd787b7d66a8c @kevin1024 committed Jul 2, 2012
Showing with 18 additions and 21 deletions.
  1. +16 −18 test.py
  2. +2 −3 vcr/stubs.py
View
34 test.py
@@ -39,9 +39,9 @@ def test_multiple_requests(self):
body2 = urllib2.urlopen('http://httpbin.org/get').read()
with vcr.use_cassette(TEST_CASSETTE_FILE):
self.assertEqual(body1, urllib2.urlopen('http://httpbin.org/').read())
- self.assertEqual(body2, urllib2.urlopen('http://httpbin.org/get').read())
+ self.assertEqual(body2, urllib2.urlopen('http://httpbin.org/get').read())
self.assertEqual(body1, urllib2.urlopen('http://httpbin.org/').read())
- self.assertEqual(body2, urllib2.urlopen('http://httpbin.org/get').read())
+ self.assertEqual(body2, urllib2.urlopen('http://httpbin.org/get').read())
class TestHttps(unittest.TestCase):
@@ -70,35 +70,33 @@ def test_response_headers(self):
self.assertEqual(headers, urllib2.urlopen('https://httpbin.org/').info().items())
def test_get_data(self):
- TEST_DATA = urlencode({'some':1,'data':'here'})
+ TEST_DATA = urlencode({'some': 1, 'data': 'here'})
with vcr.use_cassette(TEST_CASSETTE_FILE):
body = urllib2.urlopen('https://httpbin.org/get?' + TEST_DATA).read()
self.assertEqual(body, urllib2.urlopen('https://httpbin.org/get?' + TEST_DATA).read())
def test_post_data(self):
- TEST_DATA = urlencode({'some':1,'data':'here'})
+ TEST_DATA = urlencode({'some': 1, 'data': 'here'})
with vcr.use_cassette(TEST_CASSETTE_FILE):
- body = urllib2.urlopen('https://httpbin.org/post',TEST_DATA).read()
- self.assertEqual(body, urllib2.urlopen('https://httpbin.org/post',TEST_DATA).read())
+ body = urllib2.urlopen('https://httpbin.org/post', TEST_DATA).read()
+ self.assertEqual(body, urllib2.urlopen('https://httpbin.org/post', TEST_DATA).read())
def test_post_unicode(self):
- TEST_DATA = urlencode({'snowman':u''.encode('utf-8')})
+ TEST_DATA = urlencode({'snowman': u''.encode('utf-8')})
with vcr.use_cassette(TEST_CASSETTE_FILE):
- body = urllib2.urlopen('https://httpbin.org/post',TEST_DATA).read()
- self.assertEqual(body, urllib2.urlopen('https://httpbin.org/post',TEST_DATA).read())
+ body = urllib2.urlopen('https://httpbin.org/post', TEST_DATA).read()
+ self.assertEqual(body, urllib2.urlopen('https://httpbin.org/post', TEST_DATA).read())
+
class TestCassette(unittest.TestCase):
def test_serialize_cassette(self):
c1 = Cassette()
- c1.requests = ['a','b','c']
- c1.responses = ['d','e','f']
- ser = c1.serialize()
- c2 = Cassette(ser)
- self.assertEqual(c1.requests,c2.requests)
- self.assertEqual(c1.responses,c2.responses)
-
-
-
+ c1.requests = ['a', 'b', 'c']
+ c1.responses = ['d', 'e', 'f']
+ ser = c1.serialize()
+ c2 = Cassette(ser)
+ self.assertEqual(c1.requests, c2.requests)
+ self.assertEqual(c1.responses, c2.responses)
if __name__ == '__main__':
unittest.main()
View
5 vcr/stubs.py
@@ -1,4 +1,3 @@
-import socket
from httplib import HTTPConnection, HTTPSConnection, HTTPMessage
from cStringIO import StringIO
from .files import save_cassette, load_cassette
@@ -83,8 +82,8 @@ class because HTTPConnection when this happens has been replaced
one.
"""
HTTPConnection.__init__(self, *args, **kwargs)
- self.key_file = kwargs.pop('key_file',None)
- self.cert_file = kwargs.pop('cert_file',None)
+ self.key_file = kwargs.pop('key_file', None)
+ self.cert_file = kwargs.pop('cert_file', None)
self._cassette = Cassette()
def _load_old_response(self):

0 comments on commit bf844c6

Please sign in to comment.