Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[tests] test_httprettish_httpx_session fails against httpx 0.28.0 if trio is installed #299

@stanislavlevin

Description

@stanislavlevin

In downstream testing the tests environment is not locked and extra dependencies can be installed.
This happens for mocket where trio is indirectly pulled. It was not a problem (all the tests passed) till httpx 0.28.0 which triggers the tests failure:

============================= FAILURES =============================
________ HttpxEntryTestCase.test_httprettish_httpx_session _________

self = <tests.test_http_httpx.HttpxEntryTestCase 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:

tests/test_http_httpx.py:22: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3/site-packages/httpx/_client.py:1402: in __init__
    self._transport = self._init_transport(
/usr/lib/python3/site-packages/httpx/_client.py:1445: in _init_transport
    return AsyncHTTPTransport(
/usr/lib/python3/site-packages/httpx/_transports/default.py:294: in __init__
    import httpcore
/usr/lib/python3/site-packages/httpcore/__init__.py:1: in <module>
    from ._api import request, stream
/usr/lib/python3/site-packages/httpcore/_api.py:7: in <module>
    from ._sync.connection_pool import ConnectionPool
/usr/lib/python3/site-packages/httpcore/_sync/__init__.py:1: in <module>
    from .connection import HTTPConnection
/usr/lib/python3/site-packages/httpcore/_sync/connection.py:14: in <module>
    from .._synchronization import Lock
/usr/lib/python3/site-packages/httpcore/_synchronization.py:12: in <module>
    import trio
/usr/lib/python3/site-packages/trio/__init__.py:25: in <module>
    from . import abc, from_thread, lowlevel, socket, to_thread
/usr/lib/python3/site-packages/trio/socket.py:16: in <module>
    from . import _socket
/usr/lib/python3/site-packages/trio/_socket.py:545: in <module>
    class SocketType:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

...

        if sys.platform != "win32" or (
            not TYPE_CHECKING and hasattr(_stdlib_socket.socket, "sendmsg")
        ):
    
>           @_wraps(_stdlib_socket.socket.sendmsg, assigned=(), updated=())
E           AttributeError: type object 'MocketSocket' has no attribute 'sendmsg'

/usr/lib/python3/site-packages/trio/_socket.py:758: AttributeError

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