diff options
author | Gabriel Falcão <gabriel@nacaolivre.org> | 2021-01-06 03:35:36 +0100 |
---|---|---|
committer | Gabriel Falcão <gabriel@nacaolivre.org> | 2021-01-06 03:35:36 +0100 |
commit | af34a7aa2b0cdd655a7d2a7298a7472de518c616 (patch) | |
tree | 32ab5f0447a8324b318c3721941a0c33b1c73bbf | |
parent | b55eaaf5255d62ffa63726ce684e86ca9836e1aa (diff) | |
download | httpretty-af34a7aa2b0cdd655a7d2a7298a7472de518c616.tar.gz |
prevent exception from re-applying monkey patches. closes #406
-rw-r--r-- | httpretty/core.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/httpretty/core.py b/httpretty/core.py index 38e6f6f..924551e 100644 --- a/httpretty/core.py +++ b/httpretty/core.py @@ -482,7 +482,8 @@ class fakesock(object): self.truesock = self.create_socket() elif not self.truesock: raise UnmockedError() - with restored_libs(): + undo_patch_socket() + try: hostname = self._address[0] port = 80 if len(self._address) == 2: @@ -495,6 +496,9 @@ class fakesock(object): sock.connect(self._address) self.__truesock_is_connected__ = True self.truesock = sock + finally: + apply_patch_socket() + return self.truesock def real_socket_is_connected(self): |