Content-Length: 35778 | pFad | https://docs.astral.sh/ruff/rules/pytest-incorrect-fixture-name-underscore/

pytest-incorrect-fixture-name-underscore (PT005) | Ruff
Skip to content

pytest-incorrect-fixture-name-underscore (PT005)

Derived from the flake8-pytest-style linter.

Warning: This rule has been removed and its documentation is only available for historical reasons.

Removal

This rule has been removed because marking fixtures that do not return a value with an underscore isn't a practice recommended by the pytest community.

What it does

Checks for pytest fixtures that return a value, but are named with a leading underscore.

Why is this bad?

By convention, fixtures that don't return a value should be named with a leading underscore, while fixtures that do return a value should not.

This rule ignores abstract fixtures.

Example

import pytest


@pytest.fixture()
def _some_object():
    return SomeClass()


@pytest.fixture()
def _some_object_with_cleanup():
    obj = SomeClass()
    yield obj
    obj.cleanup()

Use instead:

import pytest


@pytest.fixture()
def some_object():
    return SomeClass()


@pytest.fixture()
def some_object_with_cleanup():
    obj = SomeClass()
    yield obj
    obj.cleanup()

References









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://docs.astral.sh/ruff/rules/pytest-incorrect-fixture-name-underscore/

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy