Skip to content

1.0.3: pytest fails in 5 units #889

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kloczek opened this issue Feb 14, 2024 · 2 comments
Closed

1.0.3: pytest fails in 5 units #889

kloczek opened this issue Feb 14, 2024 · 2 comments

Comments

@kloczek
Copy link

kloczek commented Feb 14, 2024

I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

  • python3 -sBm build -w --no-isolation
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using 'installer` module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")
Here is pytest output:
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-httpcore-1.0.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-httpcore-1.0.3-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' -p no:randomly
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/httpcore-1.0.3
configfile: pytest.ini
plugins: httpbin-2.0.0, asyncio-0.23.5, trio-0.8.0, anyio-4.2.0
asyncio: mode=auto
collected 213 items

tests/_async/test_connection.py ..................                       [  8%]
tests/_async/test_connection_pool.py ..............................FFF   [ 23%]
tests/_async/test_http11.py ........................                     [ 35%]
tests/_async/test_http2.py ....................                          [ 44%]
tests/_async/test_http_proxy.py ..........                               [ 49%]
tests/_async/test_integration.py ......                                  [ 52%]
tests/_async/test_socks_proxy.py ..........                              [ 56%]
tests/_sync/test_connection.py .........                                 [ 61%]
tests/_sync/test_connection_pool.py ..................                   [ 69%]
tests/_sync/test_http11.py ............                                  [ 75%]
tests/_sync/test_http2.py ..........                                     [ 79%]
tests/_sync/test_http_proxy.py .....                                     [ 82%]
tests/_sync/test_integration.py ...                                      [ 83%]
tests/_sync/test_socks_proxy.py .....                                    [ 85%]
tests/test_api.py ...                                                    [ 87%]
tests/test_cancellations.py ....XXX....XXX                               [ 93%]
tests/test_models.py ...........FF                                       [100%]

=================================== FAILURES ===================================
_______________________ test_connection_pool_concurrency _______________________

self = <Coroutine test_connection_pool_concurrency>

    def runtest(self) -> None:
        self.obj = wrap_in_sync(
            # https://github.com/pytest-dev/pytest-asyncio/issues/596
            self.obj,  # type: ignore[has-type]
        )
>       super().runtest()

/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:440:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:905: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

coro_or_future = None

    def ensure_future(coro_or_future, *, loop=None):
        """Wrap a coroutine or an awaitable in a future.

        If the argument is a Future, it is returned directly.
        """
        if coroutines.iscoroutine(coro_or_future):
            if loop is None:
                loop = events.get_event_loop()
            task = loop.create_task(coro_or_future)
            if task._source_traceback:
                del task._source_traceback[-1]
            return task
        elif futures.isfuture(coro_or_future):
            if loop is not None and loop is not futures._get_loop(coro_or_future):
                raise ValueError('The future belongs to a different loop than '
                                 'the one specified as the loop argument')
            return coro_or_future
        elif inspect.isawaitable(coro_or_future):
            return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
        else:
>           raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
                            'required')
E           TypeError: An asyncio.Future, a coroutine or an awaitable is required

/usr/lib64/python3.8/asyncio/tasks.py:684: TypeError
_____________ test_connection_pool_concurrency_same_domain_closing _____________

self = <Coroutine test_connection_pool_concurrency_same_domain_closing>

    def runtest(self) -> None:
        self.obj = wrap_in_sync(
            # https://github.com/pytest-dev/pytest-asyncio/issues/596
            self.obj,  # type: ignore[has-type]
        )
>       super().runtest()

/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:440:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:905: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

coro_or_future = None

    def ensure_future(coro_or_future, *, loop=None):
        """Wrap a coroutine or an awaitable in a future.

        If the argument is a Future, it is returned directly.
        """
        if coroutines.iscoroutine(coro_or_future):
            if loop is None:
                loop = events.get_event_loop()
            task = loop.create_task(coro_or_future)
            if task._source_traceback:
                del task._source_traceback[-1]
            return task
        elif futures.isfuture(coro_or_future):
            if loop is not None and loop is not futures._get_loop(coro_or_future):
                raise ValueError('The future belongs to a different loop than '
                                 'the one specified as the loop argument')
            return coro_or_future
        elif inspect.isawaitable(coro_or_future):
            return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
        else:
>           raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
                            'required')
E           TypeError: An asyncio.Future, a coroutine or an awaitable is required

/usr/lib64/python3.8/asyncio/tasks.py:684: TypeError
____________ test_connection_pool_concurrency_same_domain_keepalive ____________

self = <Coroutine test_connection_pool_concurrency_same_domain_keepalive>

    def runtest(self) -> None:
        self.obj = wrap_in_sync(
            # https://github.com/pytest-dev/pytest-asyncio/issues/596
            self.obj,  # type: ignore[has-type]
        )
>       super().runtest()

/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:440:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:905: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

coro_or_future = None

    def ensure_future(coro_or_future, *, loop=None):
        """Wrap a coroutine or an awaitable in a future.

        If the argument is a Future, it is returned directly.
        """
        if coroutines.iscoroutine(coro_or_future):
            if loop is None:
                loop = events.get_event_loop()
            task = loop.create_task(coro_or_future)
            if task._source_traceback:
                del task._source_traceback[-1]
            return task
        elif futures.isfuture(coro_or_future):
            if loop is not None and loop is not futures._get_loop(coro_or_future):
                raise ValueError('The future belongs to a different loop than '
                                 'the one specified as the loop argument')
            return coro_or_future
        elif inspect.isawaitable(coro_or_future):
            return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
        else:
>           raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
                            'required')
E           TypeError: An asyncio.Future, a coroutine or an awaitable is required

/usr/lib64/python3.8/asyncio/tasks.py:684: TypeError
___________________________ test_response_async_read ___________________________

self = <Coroutine test_response_async_read>

    def runtest(self) -> None:
        self.obj = wrap_in_sync(
            # https://github.com/pytest-dev/pytest-asyncio/issues/596
            self.obj,  # type: ignore[has-type]
        )
>       super().runtest()

/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:440:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:905: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

coro_or_future = None

    def ensure_future(coro_or_future, *, loop=None):
        """Wrap a coroutine or an awaitable in a future.

        If the argument is a Future, it is returned directly.
        """
        if coroutines.iscoroutine(coro_or_future):
            if loop is None:
                loop = events.get_event_loop()
            task = loop.create_task(coro_or_future)
            if task._source_traceback:
                del task._source_traceback[-1]
            return task
        elif futures.isfuture(coro_or_future):
            if loop is not None and loop is not futures._get_loop(coro_or_future):
                raise ValueError('The future belongs to a different loop than '
                                 'the one specified as the loop argument')
            return coro_or_future
        elif inspect.isawaitable(coro_or_future):
            return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
        else:
>           raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
                            'required')
E           TypeError: An asyncio.Future, a coroutine or an awaitable is required

/usr/lib64/python3.8/asyncio/tasks.py:684: TypeError
________________________ test_response_async_streaming _________________________

self = <Coroutine test_response_async_streaming>

    def runtest(self) -> None:
        self.obj = wrap_in_sync(
            # https://github.com/pytest-dev/pytest-asyncio/issues/596
            self.obj,  # type: ignore[has-type]
        )
>       super().runtest()

/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:440:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/pytest_asyncio/plugin.py:905: in inner
    task = asyncio.ensure_future(coro, loop=_loop)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

coro_or_future = None

    def ensure_future(coro_or_future, *, loop=None):
        """Wrap a coroutine or an awaitable in a future.

        If the argument is a Future, it is returned directly.
        """
        if coroutines.iscoroutine(coro_or_future):
            if loop is None:
                loop = events.get_event_loop()
            task = loop.create_task(coro_or_future)
            if task._source_traceback:
                del task._source_traceback[-1]
            return task
        elif futures.isfuture(coro_or_future):
            if loop is not None and loop is not futures._get_loop(coro_or_future):
                raise ValueError('The future belongs to a different loop than '
                                 'the one specified as the loop argument')
            return coro_or_future
        elif inspect.isawaitable(coro_or_future):
            return ensure_future(_wrap_awaitable(coro_or_future), loop=loop)
        else:
>           raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
                            'required')
E           TypeError: An asyncio.Future, a coroutine or an awaitable is required

/usr/lib64/python3.8/asyncio/tasks.py:684: TypeError
=================================== XPASSES ====================================
=========================== short test summary info ============================
XPASS tests/test_cancellations.py::test_h2_timeout_during_handshake[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_request[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_response[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_handshake[trio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_request[trio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_response[trio]
FAILED tests/_async/test_connection_pool.py::test_connection_pool_concurrency
FAILED tests/_async/test_connection_pool.py::test_connection_pool_concurrency_same_domain_closing
FAILED tests/_async/test_connection_pool.py::test_connection_pool_concurrency_same_domain_keepalive
FAILED tests/test_models.py::test_response_async_read - TypeError: An asyncio...
FAILED tests/test_models.py::test_response_async_streaming - TypeError: An as...
=================== 5 failed, 202 passed, 6 xpassed in 4.58s ===================
List of installed modules in build env:
Package                   Version
------------------------- ---------
anyio                     4.2.0
attrs                     23.2.0
autoflake                 2.2.0
blinker                   1.6.2
Brotli                    1.1.0
build                     1.0.3
certifi                   2023.7.22
cffi                      1.16.0
click                     8.1.7
coverage                  7.4.1
cppclean                  0.13
cryptography              42.0.2
decorator                 5.1.1
distro                    1.9.0
dnf                       4.19.0
editables                 0.5
exceptiongroup            1.1.3
flasgger                  0.9.7.1
Flask                     3.0.2
gpg                       1.23.2
greenlet                  3.0.3
h11                       0.14.0
h2                        4.1.0
hatch-fancy-pypi-readme   24.1.0
hatchling                 1.21.1
hpack                     4.0.0
httpbin                   0.10.1
Hypercorn                 0.14.4
hyperframe                6.0.1
idna                      3.6
importlib_metadata        7.0.1
importlib_resources       6.1.1
iniconfig                 2.0.0
installer                 0.7.0
isort                     5.13.2
itsdangerous              2.1.2
Jinja2                    3.1.3
jsonschema                4.19.1
jsonschema-specifications 2023.7.1
libdnf                    0.73.0
MarkupSafe                2.1.3
mistune                   2.0.5
outcome                   1.2.0
packaging                 23.2
pathspec                  0.12.1
pkgutil_resolve_name      1.3.10
pluggy                    1.3.0
ply                       3.11
priority                  2.0.0
pycparser                 2.21
pyflakes                  3.1.0
pyproject_hooks           1.0.0
pytest                    8.0.0
pytest-asyncio            0.23.5
pytest-httpbin            2.0.0
pytest-trio               0.8.0
python-dateutil           2.8.2
PyYAML                    6.0.1
referencing               0.30.2
rpds-py                   0.18.0
six                       1.16.0
sniffio                   1.3.0
socksio                   1.0.0
sortedcontainers          2.4.0
tomli                     2.0.1
trio                      0.23.1
trove-classifiers         2024.2.9
trustme                   1.1.0
typing_extensions         4.9.0
uvicorn                   0.27.1
Werkzeug                  3.0.1
wheel                     0.42.0
wsproto                   1.2.0
zipp                      3.17.0

Please let me know if you need more details or want me to perform some diagnostics.

@T-256
Copy link
Contributor

T-256 commented Feb 15, 2024

Uninstall pytest-asyncio
Ref: python-trio/pytest-trio#88 (comment)

@kloczek
Copy link
Author

kloczek commented Feb 15, 2024

Indeed it solved the issue

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-httpcore-1.0.3-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-httpcore-1.0.3-2.fc35.x86_64/us
r/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -m 'not network' -p no:randomly
============================= test session starts ==============================
platform linux -- Python 3.8.18, pytest-8.0.0, pluggy-1.3.0
rootdir: /home/tkloczko/rpmbuild/BUILD/httpcore-1.0.3
configfile: pyproject.toml
plugins: httpbin-2.0.0, trio-0.8.0, anyio-4.2.0
collected 213 items

tests/_async/test_connection.py ..................                       [  8%]
tests/_async/test_connection_pool.py .................................   [ 23%]
tests/_async/test_http11.py ........................                     [ 35%]
tests/_async/test_http2.py ....................                          [ 44%]
tests/_async/test_http_proxy.py ..........                               [ 49%]
tests/_async/test_integration.py ......                                  [ 52%]
tests/_async/test_socks_proxy.py ..........                              [ 56%]
tests/_sync/test_connection.py .........                                 [ 61%]
tests/_sync/test_connection_pool.py ..................                   [ 69%]
tests/_sync/test_http11.py ............                                  [ 75%]
tests/_sync/test_http2.py ..........                                     [ 79%]
tests/_sync/test_http_proxy.py .....                                     [ 82%]
tests/_sync/test_integration.py ...                                      [ 83%]
tests/_sync/test_socks_proxy.py .....                                    [ 85%]
tests/test_api.py ...                                                    [ 87%]
tests/test_cancellations.py ....XXX....XXX                               [ 93%]
tests/test_models.py .............                                       [100%]

=================================== XPASSES ====================================
=========================== short test summary info ============================
XPASS tests/test_cancellations.py::test_h2_timeout_during_handshake[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_request[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_response[asyncio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_handshake[trio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_request[trio]
XPASS tests/test_cancellations.py::test_h2_timeout_during_response[trio]
======================== 207 passed, 6 xpassed in 4.37s ========================

Thank you 👍
Closing.

@kloczek kloczek closed this as completed Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants