diff --git a/httpretty/core.py b/httpretty/core.py index 83133545..bd04d6e3 100644 --- a/httpretty/core.py +++ b/httpretty/core.py @@ -703,6 +703,14 @@ def __getattr__(self, name): # calls (or can they?) self.truesock = self.create_socket() elif not self.truesock: + # Special case for + # `hasattr(sock, "version")` call added in urllib3>=1.26. + if name == 'version': + raise AttributeError( + "HTTPretty synthesized this error to fix urllib3 compatibility " + "(see issue https://github.com/gabrielfalcao/HTTPretty/issues/409). " + "Please open an issue if this error causes further unexpected issues." + ) raise UnmockedError() return getattr(self.truesock, name)