From e1f65bcbdc8e7c408a9787b59f57469da918c707 Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Fri, 26 Dec 2014 05:07:02 -0500 Subject: [PATCH] Add force reset around calls to actual connection from stubs, to ensure compatibility with version of httplib/urlib2 in python 2.7.9. Closes #130. --- vcr/stubs/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/vcr/stubs/__init__.py b/vcr/stubs/__init__.py index 92a5a017..bad8a834 100644 --- a/vcr/stubs/__init__.py +++ b/vcr/stubs/__init__.py @@ -236,12 +236,16 @@ def getresponse(self, _=False): self._vcr_request ) ) - self.real_connection.request( - method=self._vcr_request.method, - url=self._url(self._vcr_request.uri), - body=self._vcr_request.body, - headers=self._vcr_request.headers, - ) + # This is imported here to avoid circular import. + # TODO(@IvanMalison): Refactor to allow normal import. + from vcr.patch import force_reset + with force_reset(): + self.real_connection.request( + method=self._vcr_request.method, + url=self._url(self._vcr_request.uri), + body=self._vcr_request.body, + headers=self._vcr_request.headers, + ) # get the response response = self.real_connection.getresponse()