You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifself.funcnamefilter(name) andfixtures.getfixturemarker(obj):
self.warn(PytestCollectionWarning(f" cannot collect test function '{name}' ,because it uses the decorator '@pytest.fixture' and becomes a fixture"))
returnFasle
When communicating with pytest beginners, it’s common to encounter code like this:
While the code meets functional requirements:
login
first, then executescreate_data
.It also confuses them: Why are there 2 test cases, but only 1 appears in the terminal and reports?
This confusion arises because in most tutorials, blogs, and examples, test cases and fixtures share similarities:
Currently, using
@pytest.mark
in fixtures raises a warning.Should we also issue a warning when
@pytest.fixture
is used for test cases?This could make it clearer that test cases and fixtures are fundamentally different, and their decorators are not interchangeable.
The text was updated successfully, but these errors were encountered: