mirror of
https://github.com/kevin1024/vcrpy.git
synced 2025-12-09 09:13:23 +00:00
Only have a sock attribute after connecting
This commit is contained in:
committed by
Samuel Fekete
parent
bed9e520a3
commit
eb4774a7d2
@@ -171,6 +171,8 @@ class VCRConnection(object):
|
|||||||
# allows me to compare the entire length of the response to see if it
|
# allows me to compare the entire length of the response to see if it
|
||||||
# exists in the cassette.
|
# exists in the cassette.
|
||||||
|
|
||||||
|
self._sock = VCRFakeSocket()
|
||||||
|
|
||||||
def putrequest(self, method, url, *args, **kwargs):
|
def putrequest(self, method, url, *args, **kwargs):
|
||||||
"""
|
"""
|
||||||
httplib gives you more than one way to do it. This is a way
|
httplib gives you more than one way to do it. This is a way
|
||||||
@@ -294,11 +296,13 @@ class VCRConnection(object):
|
|||||||
with force_reset():
|
with force_reset():
|
||||||
return self.real_connection.connect(*args, **kwargs)
|
return self.real_connection.connect(*args, **kwargs)
|
||||||
|
|
||||||
|
self._sock = VCRFakeSocket()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def sock(self):
|
def sock(self):
|
||||||
if self.real_connection.sock:
|
if self.real_connection.sock:
|
||||||
return self.real_connection.sock
|
return self.real_connection.sock
|
||||||
return VCRFakeSocket()
|
return self._sock
|
||||||
|
|
||||||
@sock.setter
|
@sock.setter
|
||||||
def sock(self, value):
|
def sock(self, value):
|
||||||
@@ -316,6 +320,8 @@ class VCRConnection(object):
|
|||||||
with force_reset():
|
with force_reset():
|
||||||
self.real_connection = self._baseclass(*args, **kwargs)
|
self.real_connection = self._baseclass(*args, **kwargs)
|
||||||
|
|
||||||
|
self._sock = None
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
"""
|
"""
|
||||||
We need to define this because any attributes that are set on the
|
We need to define this because any attributes that are set on the
|
||||||
|
|||||||
Reference in New Issue
Block a user