Skip to content

pytest-asyncio doesn't work with trio fixtures #298

Closed
@flolf

Description

@flolf

My pytest.ini file contains the following:

asyncio_mode = strict

I have the following fixture

@pytest_trio.trio_fixture
async def a_fixture():
    async with trio_asyncio.open_loop():
        ...

And the following test:

@pytest.mark.trio
async def test_something(a_fixture):
    ...

Unfortunately the pytest collection fails at the fixture level:

/mnt/harmonix_vol2/soporifix_vol3/user/home/atl/ops3venv8_1/lib/python3.8/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
/mnt/harmonix_vol2/soporifix_vol3/user/home/atl/ops3venv8_1/lib/python3.8/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
/mnt/harmonix_vol2/soporifix_vol3/user/home/atl/ops3venv8_1/lib/python3.8/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
/mnt/harmonix_vol2/soporifix_vol3/user/home/atl/ops3venv8_1/lib/python3.8/site-packages/pytest_asyncio/plugin.py:327: in pytest_pycollect_makeitem
    _preprocess_async_fixtures(collector.config, _HOLDER)
/mnt/harmonix_vol2/soporifix_vol3/user/home/atl/ops3venv8_1/lib/python3.8/site-packages/pytest_asyncio/plugin.py:244: in _preprocess_async_fixtures
    assert _has_explicit_asyncio_mark(fixturedef.func)
E   AssertionError: assert False
E    +  where False = _has_explicit_asyncio_mark(<function server_client at 0x7f0ef019ff70>)

Why is pytest-asyncio not recognising the trio fixture?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions