Regression: in 3.10 tests are no longer de-dupped resulting in mutations propagating through parameterized test runs #4322
Labels
status: needs information
reporter needs to provide more information; can be closed after 2 or more weeks of inactivity
topic: collection
related to the collection phase
type: bug
problem that needs to be addressed
Uh oh!
There was an error while loading. Please reload this page.
What happens
In python 2 with pytest 3.10, when you pass a file or directory argument to
pytest
multiple times, it executes tests multiple times instead of once. This can result in parameterized tests that mutate their parameters running again with the mutations visible, causing spurious test failures.This is particularly problematic when using mocks, because the mock value gets re-used and checks such as "mock was only called once" start to fail.
This does not happen in python 3 and did not happen in previous versions of pytest.
Repro steps
Create a fresh python 2 virtual environment and install pytest 3.10
Create a file
test.py
containing the following code:Run
pytest . .
The test runs twice in the same session and fails the second time
The text was updated successfully, but these errors were encountered: