Current Behavior: Calling request.getfixturevalue(name) with the name of an async fixture raises a RuntimeError.
Expected Behavior: Calling request.getfixturevalue(name) with the name of an async fixture should initialize the fixture correctly.
import pytest
# This works
async def test_direct_fixture(fixture1):
assert True
# This not
async def test_get_fixturevalue_async(request):
x = request.getfixturevalue("fixture1")
Traceback
tests\test_getfixturevalue_async.py:7 (test_get_fixturevalue_async)
request = <FixtureRequest for <Coroutine test_get_fixturevalue_async>>
async def test_get_fixturevalue_async(request):
> x = request.getfixturevalue("fixture1")
test_getfixturevalue_async.py:9:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\.venv\Lib\site-packages\_pytest\fixtures.py:532: in getfixturevalue
fixturedef = self._get_active_fixturedef(argname)
..\.venv\Lib\site-packages\_pytest\fixtures.py:617: in _get_active_fixturedef
fixturedef.execute(request=subrequest)
..\.venv\Lib\site-packages\_pytest\fixtures.py:1091: in execute
result = ihook.pytest_fixture_setup(fixturedef=self, request=request)
..\.venv\Lib\site-packages\pluggy\_hooks.py:513: in __call__
return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
..\.venv\Lib\site-packages\pluggy\_manager.py:120: in _hookexec
return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
..\.venv\Lib\site-packages\_pytest\setuponly.py:36: in pytest_fixture_setup
return (yield)
..\.venv\Lib\site-packages\_pytest\fixtures.py:1140: in pytest_fixture_setup
result = call_fixture_func(fixturefunc, request, kwargs)
..\.venv\Lib\site-packages\_pytest\fixtures.py:898: in call_fixture_func
fixture_result = fixturefunc(**kwargs)
..\.venv\Lib\site-packages\pytest_asyncio\plugin.py:366: in _async_fixture_wrapper
return event_loop.run_until_complete(setup())
C:\Python\3.11\Lib\asyncio\base_events.py:630: in run_until_complete
self._check_running()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <ProactorEventLoop running=False closed=False debug=False>
def _check_running(self):
if self.is_running():
> raise RuntimeError('This event loop is already running')
E RuntimeError: This event loop is already running
C:\Python\3.11\Lib\asyncio\base_events.py:589: RuntimeError
Current Behavior: Calling
request.getfixturevalue(name)
with the name of an async fixture raises aRuntimeError
. Expected Behavior: Callingrequest.getfixturevalue(name)
with the name of an async fixture should initialize the fixture correctly.Tested on Windows 11 23H2 with Python 3.11
Installed packages
conftest.py
tests/test_getfixturevalue_async.py
Traceback