mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-10 09:35:34 +00:00
Attributes set on VCRConnection now also get set on the real_connection
This commit is contained in:
@@ -315,6 +315,22 @@ class VCRConnection(object):
|
||||
with force_reset():
|
||||
self.real_connection = self._baseclass(*args, **kwargs)
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
"""
|
||||
We need to define this because any attributes that are set on the
|
||||
VCRConnection need to be propogated to the real connection.
|
||||
|
||||
For example, urllib3 will set certain attributes on the connection,
|
||||
such as 'ssl_version'. These attributes need to get set on the real
|
||||
connection to have the correct and expected behavior.
|
||||
"""
|
||||
try:
|
||||
setattr(self.real_connection, name, value)
|
||||
except AttributeError: # raised if real_connection has not been set yet
|
||||
pass
|
||||
|
||||
super(VCRConnection, self).__setattr__(name, value)
|
||||
|
||||
|
||||
class VCRHTTPConnection(VCRConnection):
|
||||
'''A Mocked class for HTTP requests'''
|
||||
|
||||
Reference in New Issue
Block a user