我已使用以下代码将 pytest-asyncio 添加到我的诗歌测试和开发组中:
async def blah():
return 1
@pytest.mark.asyncio
async def test_me(mock_client, mock_config, event_loop):
res = await blah()
assert 1 == res
当我运行
poetry run pytest
时,我收到此警告:
/Users/ykhaburzaniya/Library/Caches/pypoetry/virtualenvs/alakazam-6HJyiZWL-py3.11/lib/python3.11/site-packages/pytest_asyncio/plugin.py:884: DeprecationWarning: There is no current event loop
_loop = asyncio.get_event_loop()
在我的诗歌.lock 中,我有 pytest-asyncio 版本 =“0.23.3”。
我该怎么做才能消除这个警告?
Python 版本很重要。
目前,如果我在 3.11.0 中使用它,则会出现相同的警告,但在 3.11.7 以上时不会出现警告。