]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
fix self.closed in python3, and request must inherit from httprequest for httplib2
authorKevin McCarthy <me@kevinmccarthy.org>
Sun, 9 Mar 2014 07:11:50 +0000 (21:11 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 9 Mar 2014 07:11:50 +0000 (21:11 -1000)
vcr/stubs/__init__.py

index 4345e779790db5dc14f560879b7d773503a3182e..82588ae3818bfbec7467e50c1b28047acf658093 100644 (file)
@@ -32,7 +32,7 @@ def parse_headers(header_list):
     headers = b"".join(header_list) + b"\r\n"
     return compat.get_httpmessage(headers)
 
-class VCRHTTPResponse(object):
+class VCRHTTPResponse(HTTPResponse):
     """
     Stub reponse class that gets returned instead of a HTTPResponse
     """
@@ -42,13 +42,20 @@ class VCRHTTPResponse(object):
         self.status = self.code = recorded_response['status']['code']
         self.version = None
         self._content = BytesIO(self.recorded_response['body']['string'])
-        self.closed = False
+        self._closed = False
 
         headers = self.recorded_response['headers']
         self.msg = parse_headers(headers)
 
         self.length = compat.get_header(self.msg, 'content-length') or None
 
+    @property
+    def closed(self):
+        # in python3, I can't change the value of self.closed.  So I'm twiddling
+        # self._closed and using this property to shadow the real self.closed
+        # from the superclass
+        return self._closed
+
     def read(self, *args, **kwargs):
         return self._content.read(*args, **kwargs)
 
@@ -56,7 +63,7 @@ class VCRHTTPResponse(object):
         return self._content.readline(*args, **kwargs)
 
     def close(self):
-        self.closed = True
+        self._closed = True
         return True
 
     def getcode(self):