Provide async `getfixturevalue()` method on anyio
- Dominant language
- Python
- Stars
- 2.5k
- Forks
- 260
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 17
Description
### Things to check first
- [X] I have searched the existing issues and didn't find my feature already requested there
### Feature description
Pytest allows to retrieve a fixture value by injecting the fixture as a function argument or by using `request.getfixturevalue()`. The latter fails to provide the value of an async fixture.
```py
import pytest
pytestmark = pytest.mark.anyio
@pytest.fixture
def anyio_backend():
return "asyncio"
@pytest.fixture
async def f():
return 1
async def test_problem(request):
assert request.getfixturevalue('f') == 1
async def test_ok(f):
assert f == 1
```
### Use case
According to the docs [1], `getfixturevalue()` runs a fixture dynamically. This feature is not available in anyio currently for async fixtures. However, I would like to make use of it to decide if I need to run a specific fixture based on the value of another fixture.
From the docs:
> Dynamically run a named fixture function.
>
> Declaring fixtures via function argument is recommended where possible. But if you can only decide whether to use another > fixture at test setup time, you may use this function to retrieve it inside a fixture or test function body.
[1] https://docs.pytest.org/en/7.1.x/reference/reference.html
Contributor guide
Assessment
This issue has not been assessed yet.