Skip to content

Fixtures that are used in pytest.fixture(params=[...]) are marked as unused #28

@sobolevn

Description

@sobolevn

I am using this approach in some of my fixtures:

@pytest.fixture()
def async_wrapper():
    """Fixture to convert all regular functions into async ones."""
    def factory(template: str) -> str:
        return template.replace(
            'def ', 'async def ',
        ).replace(
            'with ', 'async with ',
        ).replace(
            'for ', 'async for ',
        )
    return factory


@pytest.fixture()
def regular_wrapper():
    """Fixture to return regular functions without modifications."""
    def factory(template: str) -> str:
        return template
    return factory


@pytest.fixture(params=['async_wrapper', 'regular_wrapper'])
def mode(request):
    """Fixture that returns either `async` or regular functions."""
    return request.getfixturevalue(request.param)

And pytest --dead-fixtures marks both of them as unused:

» pytest --dead-fixtures --dup-fixtures

Hey there, I believe the following fixture(s) are not being used:
Fixture name: async_wrapper, location: tests/test_visitors/conftest.py:65
Fixture name: regular_wrapper, location: tests/test_visitors/conftest.py:79

What can be done to suppress this error?

Source code: https://github.com/wemake-services/wemake-python-styleguide/blob/master/tests/test_visitors/conftest.py#L64-L89
Related: wemake-services/wemake-python-styleguide#1017

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions