Skip to content

urllib3 2.3.0 breaks tests #3101

Closed
@penguinpee

Description

Fedora just updated to urllib3 2.3.0 and it broke PyGithub's tests. 906 tests in total fail. It appears to be an issue with httpretty going by the error message and the linked ticket therein:

________________ 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: UnmockedError

The error appears to be pretty much the same for all failing tests.

To reproduce, install PyGithub in a venv with pip install and run the tests. Downgrade urllib3 with `pip install 'urllib3<2.3.0' and rerun the tests and they will succeed.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions