fixture '{name}' returns a value, remove leading underscore
This rule does not fire on abstract fixtures (those decorated with @abc.abstractmethod),
so that only the actual fixture implementations will be checked.
Bad code:
import pytest
@pytest.fixture()
def _some_object():
return SomeClass()
@pytest.fixture()
def _some_object_with_cleanup():
obj = SomeClass()
yield obj
obj.cleanup()Good code:
import pytest
@pytest.fixture()
def some_object():
return SomeClass()
@pytest.fixture()
def some_object_with_cleanup():
obj = SomeClass()
yield obj
obj.cleanup()- to enforce a naming convention for fixtures:
fixtures that don't return a value start with a leading underscore (e.g.
_patch_something), fixtures that return a value don't start with a leading underscore (e.g.some_object)
See also PT004.