Improve (beginner) UX around self vs. fixtures #12907
Labels
topic: reporting
related to terminal output and user-facing messages and errors
type: proposal
proposal for a new feature, often to gather opinions or design the API around the new feature
Something I see sometimes in my pytest company trainings is people accidentally doing:
because they're using to writing things in classes (e.g. from Java?). That results in a
which is not exactly useful if you don't know yet what a fixture is. IMHO, we should detect the
self
name here, and output an additional hint ("hint: Removeself
as this is not a method?" or somesuch).Similarly, when people start moving tests from functions to classes, they forget to add
self
, which can be very confusing in combination with fixtures:results in:
which is still somewhat clear, but depending on what you do with a fixture (e.g. passing data to a function under test), it can be quite confusing if you've never seen this kind of message before.
Maybe a bit more tricky here, but it would be nice if pytest could detect that we're in a test method, the first argument is not
self
, and the first argument is a valid fixture name. If all of those are true, that seems to be worth warning about as well.The text was updated successfully, but these errors were encountered: