From bf844c6952e3dafc6f679c5e096cd787b7d66a8c Mon Sep 17 00:00:00 2001 From: Kevin McCarthy Date: Mon, 2 Jul 2012 10:00:18 -1000 Subject: [PATCH] cleanup --- test.py | 34 ++++++++++++++++------------------ vcr/stubs.py | 5 ++--- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/test.py b/test.py index ccb2cbb..c8e926d 100644 --- a/test.py +++ b/test.py @@ -39,9 +39,9 @@ class TestHttpRequest(unittest.TestCase): 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 @@ class TestHttps(unittest.TestCase): 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() diff --git a/vcr/stubs.py b/vcr/stubs.py index 894a69f..f22ee35 100644 --- a/vcr/stubs.py +++ b/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 VCRHTTPSConnection(HTTPSConnection): 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):