Skip to content

Emit warning for shadowed tests #12794

Discussion options

You must be logged in to vote

The problem is that pytest cannot trivially do this: Outside of inspecting the ast, there is no way for pytest to find out about this - at runtime, pytest only sees the last function, because a function definition is basically just an assignment.

However, there are already plenty of linters that do detect this via the AST (ruff, mypy, flake8, pylint, your IDE probably, ...). I don't think there is much value in pytest adding all this complexity (even though I agree this is a common pitfall), since I'd expect a typical Python development environment to already take care of this.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@RonnyPfannschmidt
Comment options

Answer selected by SullivanMuse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
3 participants