0

Pytest offers a way to parametrize fixture just before running test function (documentation)

But I am trying to write async tests using AnyIO

Below is my modified code from example

import pytest


@pytest.fixture(scope="session")
def anyio_backend() -> str:
    return "asyncio"


@pytest.fixture
async def fixt(request):
    return request.param * 3


@pytest.mark.anyio
@pytest.mark.parametrize("fixt", ["a", "b"], indirect=True)
async def test_indirect(fixt):
    assert len(fixt) == 3

But despite original example code works well, my modified test encounters RuntimeError: Event loop is closed when trying to set the second value.

Is there a way to parameterize asynchronous test fixtures?

0 Answers0