-
-
Notifications
You must be signed in to change notification settings - Fork 279
Open
Description
Problem is that urllib3 now calls into httpretty.core.fakesock.socket.__getattr__ with "shutdown", which raises an error with httpretty.enable(allow_net_connect=False):
________________ ApplicationOAuth.testEnterpriseGetAccessToken _________________
self = <tests.ApplicationOAuth.ApplicationOAuth testMethod=testEnterpriseGetAccessToken>
def testEnterpriseGetAccessToken(self):
> access_token = self.ent_app.get_access_token("oauth_code_removed", state="state_removed")
tests/ApplicationOAuth.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
github/ApplicationOAuth.py:137: in get_access_token
*self._requester.requestJsonAndCheck(
github/Requester.py:586: in requestJsonAndCheck
return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
github/Requester.py:856: in requestJson
return self.__requestEncode(cnx, verb, url, parameters, headers, input, encode)
github/Requester.py:977: in __requestEncode
status, responseHeaders, output = self.__requestRaw(cnx, verb, url, requestHeaders, encoded_input)
github/Requester.py:1011: in __requestRaw
response = cnx.getresponse()
tests/Framework.py:254: in getresponse
response = self.__cnx.getresponse()
github/Requester.py:265: in getresponse
r = verb(
/usr/lib/python3.13/site-packages/requests/sessions.py:637: in post
return self.request("POST", url, data=data, json=json, **kwargs)
/usr/lib/python3.13/site-packages/requests/sessions.py:589: in request
resp = self.send(prep, **send_kwargs)
/usr/lib/python3.13/site-packages/requests/sessions.py:703: in send
r = adapter.send(request, **kwargs)
/usr/lib/python3.13/site-packages/requests/adapters.py:668: in send
resp = conn.urlopen(
/usr/lib/python3.13/site-packages/urllib3/connectionpool.py:787: in urlopen
response = self._make_request(
/usr/lib/python3.13/site-packages/urllib3/connectionpool.py:534: in _make_request
response = conn.getresponse()
/usr/lib/python3.13/site-packages/urllib3/connection.py:513: in getresponse
_shutdown = getattr(self.sock, "shutdown", None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = httpretty.core.socket("my.enterprise.com:80"), name = 'shutdown'
def __getattr__(self, name):
if name in ('getsockopt', 'selected_alpn_protocol') and not self.truesock:
self.truesock = self.create_socket()
elif httpretty.allow_net_connect and not self.truesock:
# can't call self.connect_truesock() here because we
# don't know if user wants to execute server of client
# 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('Failed to socket.{} because because a real socket does not exist'.format(name))
E httpretty.errors.UnmockedError: Failed to socket.shutdown because because a real socket does not exist
E
E Tip: You could try setting (allow_net_connect=True) to allow unregistered requests through a real TCP connection in addition to (verbose=True) to debug the issue.
/usr/lib/python3.13/site-packages/httpretty/core.py:894: UnmockedErrorpeterthomassen, juliadolgova, sterliakov, scottjmaddox, danial-k and 4 more
Metadata
Metadata
Assignees
Labels
No labels