From: Samuel Fekete Date: Fri, 3 Nov 2017 11:39:13 +0000 (+0000) Subject: fix proxy for Python 2 X-Git-Tag: v2.0.0~5^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=ff7dd06f4730041db3a9b864d6721a59dffaa94a;p=vcrpy.git fix proxy for Python 2 --- diff --git a/tests/integration/test_proxy.py b/tests/integration/test_proxy.py index a1fc003..5dfd285 100644 --- a/tests/integration/test_proxy.py +++ b/tests/integration/test_proxy.py @@ -23,8 +23,15 @@ class Proxy(SimpleHTTPServer.SimpleHTTPRequestHandler): ''' def do_GET(self): upstream_response = urlopen(self.path) - self.send_response(upstream_response.status, upstream_response.msg) - for header in upstream_response.headers.items(): + try: + status = upstream_response.status + headers = upstream_response.headers.items() + except AttributeError: + # In Python 2 the response is an addinfourl instance. + status = upstream_response.code + headers = upstream_response.info().items() + self.send_response(status, upstream_response.msg) + for header in headers: self.send_header(*header) self.end_headers() self.copyfile(upstream_response, self.wfile)