]> khamidou — GitHub mirrors - vcrpy.git/commitdiff
proxy getattr to the real connection too
authorKevin McCarthy <me@kevinmccarthy.org>
Sun, 28 May 2017 01:30:09 +0000 (15:30 -1000)
committerKevin McCarthy <me@kevinmccarthy.org>
Sun, 28 May 2017 01:40:42 +0000 (15:40 -1000)
vcr/stubs/__init__.py

index c7e39be2071007fa53c3fa8d0855576d4a8bd9f9..67cb5e7d7b57dc6b68ed337bc3247aa6d3ac7929 100644 (file)
@@ -334,6 +334,18 @@ class VCRConnection(object):
 
         super(VCRConnection, self).__setattr__(name, value)
 
+    def __getattr__(self, name):
+        """
+        Send requests for weird attributes up to the real connection
+        (counterpart to __setattr above)
+        """
+        if self.__dict__.get('real_connection'):
+            # check in case real_connection has not been set yet, such as when
+            # we're setting the real_connection itself for the first time
+            return getattr(self.real_connection, name)
+
+        return super(VCRConnection, self).__getattr__(name)
+
 
 for k, v in HTTPConnection.__dict__.items():
     if isinstance(v, staticmethod):