You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pytest-asyncio uses a marker, @pytest.mark.asyncio, with some optional parameters. To save typing, I was going to suggest my users use something like this:
These two should be equivalent, right? But they aren't. pytest-asyncio uses a pytest_pycollect_makeitem hook:
@pytest.mark.tryfirst
def pytest_pycollect_makeitem(collector, name, obj):
if collector.funcnamefilter(name) and _is_coroutine(obj):
item = pytest.Function(name, parent=collector)
if ('asyncio' in item.keywords or
'asyncio_process_pool' in item.keywords):
return list(collector._genfunctions(name, obj))
but using the pytestmark approach, the 'asyncio' keyword isn't in item.keywords.
I'm not saying pytest is doing something wrong here, I'm saying help me make this work. :)
The text was updated successfully, but these errors were encountered:
My guess is that the mark propagation mechanism is not picking up async functions, so it is a bug in pytest. The code in question is in transfer_markers function, I believe.
Sorry for not being able to help out more right now.
It turned out pytest applies the module- and class-level markers after collection, so I just made pytest-asyncio do this manually when I need it to happen.
Hi,
I'm the maintainer of pytest-asyncio.
Pytest-asyncio uses a marker,
@pytest.mark.asyncio
, with some optional parameters. To save typing, I was going to suggest my users use something like this:instead of:
These two should be equivalent, right? But they aren't. pytest-asyncio uses a
pytest_pycollect_makeitem
hook:but using the pytestmark approach, the 'asyncio' keyword isn't in
item.keywords
.I'm not saying pytest is doing something wrong here, I'm saying help me make this work. :)
The text was updated successfully, but these errors were encountered: