Skip to content

I want a rule that warns on fixtures named test_xxx #330

@jakkdl

Description

@jakkdl

Rule request

Description

Raise a warning whenever a function named test_xxx also has a pytest.fixture decorator. E.g.

@pytest.fixture()
def test_login():
    driver = get_driver()
    page = pom.LoginPage(driver)
    page.login()
    return driver

def test_create_data(test_login):
    page = pom.HomePage(test_login)
    msg = page.send_data("./data.csv")
    assert 'ok' in msg

Rationale

Functions named test_xxx gets picked up and ran by pytest, but not if they're marked with @pytest.fixture. This could be confusing for new users that have yet to fully internalize the correct concepts.

This was rejected for inclusion into pytest itself as it would be noisy, and considered better suited for a linter. See pytest-dev/pytest#12989 and pytest-dev/pytest#13051

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions