Skip to content

test_httprettish_httpx_session breaks with anyio 4.14.2 #325

Description

@mweinelt

In nixpkgs after updating anyio from 4.14.1 to 4.14.2 we saw the following test failure with mocket 3.14.2 on Python 3.14.6.

Took a quick glance at anyio changes and the only thing that stands out to me is agronholm/anyio#1208.

____________ HttpxHttpsEntryTestCase.test_httprettish_httpx_session ____________

self = <tests.test_http_httpx.HttpxHttpsEntryTestCase testMethod=test_httprettish_httpx_session>

    @async_httprettified
    async def test_httprettish_httpx_session(self):
        expected_response = {"origin": "127.0.0.1"}
    
        HTTPretty.register_uri(
            HTTPretty.GET,
            self.target_url,
            body=json.dumps(expected_response),
        )
    
        async with httpx.AsyncClient() as client:
>           response = await client.get(self.target_url)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

tests/test_http_httpx.py:42: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1768: in get
    return await self.request(
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1540: in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1629: in send
    response = await self._send_handling_auth(
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1657: in _send_handling_auth
    response = await self._send_handling_redirects(
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1694: in _send_handling_redirects
    response = await self._send_single_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_client.py:1730: in _send_single_request
    response = await transport.handle_async_request(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/bdr7gvvqix1x445dncf9svbhhb3xd5gk-python3.14-httpx-0.28.1/lib/python3.14/site-packages/httpx/_transports/default.py:394: in handle_async_request
    resp = await self._pool.handle_async_request(req)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request
    raise exc from None
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request
    response = await connection.handle_async_request(
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/connection.py:103: in handle_async_request
    return await self._connection.handle_async_request(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/http11.py:136: in handle_async_request
    raise exc
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/http11.py:86: in handle_async_request
    await self._send_request_headers(**kwargs)
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/http11.py:150: in _send_request_headers
    await self._send_event(event, timeout=timeout)
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_async/http11.py:166: in _send_event
    await self._network_stream.write(bytes_to_send, timeout=timeout)
/nix/store/dwwscq5085p0kipczn27lgqmbjhxvc7z-python3.14-httpcore-1.0.9/lib/python3.14/site-packages/httpcore/_backends/anyio.py:50: in write
    await self._stream.send(item=buffer)
/nix/store/9fgfyw3z103jfffwqfwki5n8666szh64-python3.14-anyio-4.14.2/lib/python3.14/site-packages/anyio/streams/tls.py:261: in send
    await self._call_sslobject_method(self._ssl_object.write, item)
/nix/store/9fgfyw3z103jfffwqfwki5n8666szh64-python3.14-anyio-4.14.2/lib/python3.14/site-packages/anyio/streams/tls.py:187: in _call_sslobject_method
    result = func(*args)
             ^^^^^^^^^^^
mocket/ssl/socket.py:60: in write
    return self.send(encode_to_bytes(data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
mocket/socket.py:626: in send
    self.sendall(data, *args, **kwargs)
mocket/socket.py:375: in sendall
    response = self.true_sendall(data, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <mocket.ssl.socket.MocketSSLSocket object at 0x7ffff2893380>
data = b'GET /ip HTTP/1.1\r\nHost: httpbin.local\r\nAccept: */*\r\nAccept-Encoding: gzip, deflate, br\r\nConnection: keep-alive\r\nUser-Agent: python-httpx/0.28.1\r\n\r\n'
args = (), kwargs = {}

    def true_sendall(self, data: bytes, *args: Any, **kwargs: Any) -> bytes:
        """Send data through the real socket and receive response.
    
        Args:
            data: Data to send
            *args: Additional arguments
            **kwargs: Additional keyword arguments
    
        Returns:
            Response bytes from the real socket
    
        Raises:
            StrictMocketException: If operation not allowed in STRICT mode
        """
        if not MocketMode.is_allowed(self._address):
            MocketMode.raise_not_allowed(self._address, data)
    
        # try to get the response from recordings
        if Mocket._record_storage:
            record = Mocket._record_storage.get_record(
                address=self._address,
                request=data,
            )
            if record is not None:
                return record.response
    
>       host, port = self._address
        ^^^^^^^^^^
E       TypeError: cannot unpack non-iterable NoneType object

mocket/socket.py:578: TypeError

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions