Skip to content

0.7.0: pytesty is failing #122

@kloczek

Description

@kloczek

I'm trying to package your module as rpm packag. So I'm using typical in such case build, install and test cycle used on building package from non-root account:

  • "setup.py build"
  • "setup.py install --root </install/prefix>"
  • "pytest with PYTHONPATH pointing to setearch and sitelib inside </install/prefix>

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra -qq
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /home/tkloczko/rpmbuild/BUILD/pytest-trio-0.7.0, configfile: pytest.ini
plugins: trio-0.7.0, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, toolbox-0.5, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, hypothesis-6.14.4, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0
collected 66 items

_tests/test_async_fixture.py ....x                                                                                                                                   [  7%]
_tests/test_async_yield_fixture.py ..........FF..                                                                                                                    [ 28%]
_tests/test_basic.py ..x                                                                                                                                             [ 33%]
_tests/test_clock_fixture.py .                                                                                                                                       [ 34%]
_tests/test_contextvars.py .                                                                                                                                         [ 36%]
_tests/test_fixture_mistakes.py ..............                                                                                                                       [ 57%]
_tests/test_fixture_names.py .                                                                                                                                       [ 59%]
_tests/test_fixture_nursery.py F                                                                                                                                     [ 60%]
_tests/test_fixture_ordering.py ......                                                                                                                               [ 69%]
_tests/test_hypothesis_interaction.py .......                                                                                                                        [ 80%]
_tests/test_sync_fixture.py ....                                                                                                                                     [ 86%]
_tests/test_trio_mode.py .........                                                                                                                                   [100%]Coverage.py warning: No data was collected. (no-data-collected)


================================================================================= FAILURES =================================================================================
____________________________________________________________ test_async_yield_fixture_with_nursery[Python>=36] _____________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-33/test_async_yield_fixture_with_nursery0')>
async_yield_implementation = <function async_yield_implementation.<locals>.patch_code at 0x7f6541620310>

    def test_async_yield_fixture_with_nursery(testdir, async_yield_implementation):

        testdir.makepyfile(
            async_yield_implementation(
                """
            import pytest
            import trio
            from async_generator import async_generator, yield_


            async def handle_client(stream):
                while True:
                    buff = await stream.receive_some(4)
                    await stream.send_all(buff)


            @pytest.fixture
            @async_generator
            async def server():
                async with trio.open_nursery() as nursery:
                    listeners = await nursery.start(trio.serve_tcp, handle_client, 0)
                    await yield_(listeners[0])
                    nursery.cancel_scope.cancel()


            @pytest.mark.trio
            async def test_actual_test(server):
                stream = await trio.testing.open_stream_to_socket_listener(server)
                await stream.send_all(b'ping')
                rep = await stream.receive_some(4)
                assert rep == b'ping'
        """
            )
        )

        result = testdir.runpytest()

>       result.assert_outcomes(passed=1)
E       AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...pped': 0, ...}
E         Omitting 4 identical items, use -vv to show
E         Differing items:
E         {'passed': 0} != {'passed': 1}
E         {'failed': 1} != {'failed': 0}
E         Use -v to get the full diff

/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_trio/_tests/test_async_yield_fixture.py:303: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /tmp/pytest-of-tkloczko/pytest-33/test_async_yield_fixture_with_nursery0
plugins: trio-0.7.0, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, toolbox-0.5, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, hypothesis-6.14.4, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0
collected 1 item

test_async_yield_fixture_with_nursery.py F                               [100%]

=================================== FAILURES ===================================
_______________________________ test_actual_test _______________________________

cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7f65415acca0>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

/usr/lib/python3.8/site-packages/_pytest/runner.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/runner.py:255: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.8/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
/usr/lib/python3.8/site-packages/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
/usr/lib/python3.8/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
E
E               Traceback (most recent call last):
E                 File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_trio/plugin.py", line 252, in run
E                   await self._func(**resolved_kwargs)
E               ResourceWarning: unclosed <socket.socket fd=27, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 58022), raddr=('127.0.0.1', 38539)>

/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning
=========================== short test summary info ============================
FAILED test_async_yield_fixture_with_nursery.py::test_actual_test - pytest.Py...
============================== 1 failed in 0.16s ===============================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
__________________________________________________________ test_async_yield_fixture_with_nursery[async_generator] __________________________________________________________

testdir = <Testdir local('/tmp/pytest-of-tkloczko/pytest-33/test_async_yield_fixture_with_nursery1')>
async_yield_implementation = <function async_yield_implementation.<locals>.<lambda> at 0x7f65415a4430>

    def test_async_yield_fixture_with_nursery(testdir, async_yield_implementation):

        testdir.makepyfile(
            async_yield_implementation(
                """
            import pytest
            import trio
            from async_generator import async_generator, yield_


            async def handle_client(stream):
                while True:
                    buff = await stream.receive_some(4)
                    await stream.send_all(buff)


            @pytest.fixture
            @async_generator
            async def server():
                async with trio.open_nursery() as nursery:
                    listeners = await nursery.start(trio.serve_tcp, handle_client, 0)
                    await yield_(listeners[0])
                    nursery.cancel_scope.cancel()


            @pytest.mark.trio
            async def test_actual_test(server):
                stream = await trio.testing.open_stream_to_socket_listener(server)
                await stream.send_all(b'ping')
                rep = await stream.receive_some(4)
                assert rep == b'ping'
        """
            )
        )

        result = testdir.runpytest()

>       result.assert_outcomes(passed=1)
E       AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...pped': 0, ...}
E         Omitting 4 identical items, use -vv to show
E         Differing items:
E         {'passed': 0} != {'passed': 1}
E         {'failed': 1} != {'failed': 0}
E         Use -v to get the full diff

/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_trio/_tests/test_async_yield_fixture.py:303: AssertionError
--------------------------------------------------------------------------- Captured stdout call ---------------------------------------------------------------------------
============================= test session starts ==============================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /tmp/pytest-of-tkloczko/pytest-33/test_async_yield_fixture_with_nursery1
plugins: trio-0.7.0, forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, case-1.5.3, isort-1.3.0, aspectlib-1.5.2, toolbox-0.5, mock-3.6.1, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, hypothesis-6.14.4, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0
collected 1 item

test_async_yield_fixture_with_nursery.py F                               [100%]

=================================== FAILURES ===================================
_______________________________ test_actual_test _______________________________

cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7f654153ef70>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

/usr/lib/python3.8/site-packages/_pytest/runner.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/runner.py:255: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.8/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:337: in traced_hookexec
    return outcome.get_result()
/usr/lib/python3.8/site-packages/pluggy/manager.py:335: in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
/usr/lib/python3.8/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
E
E               Traceback (most recent call last):
E                 File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_trio/plugin.py", line 252, in run
E                   await self._func(**resolved_kwargs)
E               ResourceWarning: unclosed <socket.socket fd=27, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 37162), raddr=('127.0.0.1', 40377)>

/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning
=========================== short test summary info ============================
FAILED test_async_yield_fixture_with_nursery.py::test_actual_test - pytest.Py...
============================== 1 failed in 0.24s ===============================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
_________________________________________________________________________________ test_try _________________________________________________________________________________

cls = <class '_pytest.runner.CallInfo'>, func = <function call_runtest_hook.<locals>.<lambda> at 0x7f6541374b80>, when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

/usr/lib/python3.8/site-packages/_pytest/runner.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/usr/lib/python3.8/site-packages/_pytest/runner.py:255: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
/usr/lib/python3.8/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/usr/lib/python3.8/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:88: in pytest_runtest_call
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
E
E               Traceback (most recent call last):
E                 File "/home/tkloczko/rpmbuild/BUILDROOT/python-pytest-trio-0.7.0-5.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_trio/plugin.py", line 252, in run
E                   await self._func(**resolved_kwargs)
E               ResourceWarning: unclosed <socket.socket fd=20, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 38644), raddr=('127.0.0.1', 46149)>

/usr/lib/python3.8/site-packages/_pytest/unraisableexception.py:78: PytestUnraisableExceptionWarning

---------- coverage: platform linux, python 3.8.11-final-0 -----------
Name                                                Stmts   Miss    Cover
-------------------------------------------------------------------------
pytest_trio/__init__.py                                 3      3     0.0%
pytest_trio/_tests/__init__.py                          0      0   100.0%
pytest_trio/_tests/conftest.py                          1      1     0.0%
pytest_trio/_tests/helpers.py                           8      8     0.0%
pytest_trio/_tests/test_async_fixture.py               22     22     0.0%
pytest_trio/_tests/test_async_yield_fixture.py         41     41     0.0%
pytest_trio/_tests/test_basic.py                       14     14     0.0%
pytest_trio/_tests/test_clock_fixture.py               10     10     0.0%
pytest_trio/_tests/test_contextvars.py                 26     26     0.0%
pytest_trio/_tests/test_fixture_mistakes.py            41     41     0.0%
pytest_trio/_tests/test_fixture_names.py               12     12     0.0%
pytest_trio/_tests/test_fixture_nursery.py             15     15     0.0%
pytest_trio/_tests/test_fixture_ordering.py            29     29     0.0%
pytest_trio/_tests/test_hypothesis_interaction.py      34     34     0.0%
pytest_trio/_tests/test_sync_fixture.py                20     20     0.0%
pytest_trio/_tests/test_trio_mode.py                   53     53     0.0%
pytest_trio/_version.py                                 1      1     0.0%
pytest_trio/enable_trio_mode.py                         6      6     0.0%
pytest_trio/plugin.py                                 241    241     0.0%
-------------------------------------------------------------------------
TOTAL                                                 577    577     0.0%

========================================================================= short test summary info ==========================================================================
XFAIL _tests/test_async_fixture.py::test_raise_in_async_fixture_cause_pytest_error
  Not implemented yet
XFAIL _tests/test_basic.py::test_sync_function_with_trio_mark
  Raises pytest internal error so far...
FAILED _tests/test_async_yield_fixture.py::test_async_yield_fixture_with_nursery[Python>=36] - AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0,...p...
FAILED _tests/test_async_yield_fixture.py::test_async_yield_fixture_with_nursery[async_generator] - AssertionError: assert {'errors': 0,...pped': 0, ...} == {'errors': 0...
FAILED _tests/test_fixture_nursery.py::test_try - pytest.PytestUnraisableExceptionWarning: Exception ignored in: <socket.socket fd=-1, family=AddressFamily.AF_INET, type...
================================================================= 3 failed, 61 passed, 2 xfailed in 18.17s =================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions