pytest-dev / pytest

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing
https://pytest.org
MIT License
11.67k stars 2.6k forks source link

pytest and pytest-xdist plugin with `--snapshot-update -n auto` deletes all snapshots on parallel executions #9600

Closed Sharu95 closed 2 years ago

Sharu95 commented 2 years ago

Description

Currently working on optimizing some pipelines where I discovered that pytest + pytest-xdist behaves different with the -n flag combined with --snapshot-update. The issue arised while using tox, but is replicated with only pytest, pytest-xdist and syrupy. A minimal codebase is provided to replicate the results further down.

Actual outcome All snapshots (new and old) are deleted when tests are run with --snapshot-update -n auto Expected outcome All old snapshots should not be deleted and a new snapshot should be added with --snapshot-update -n auto

Steps to reproduce

  1. Create initial snapshots with pytest --snapshot-update
  2. Add a new test to the test-file
  3. Run pytest --snapshot-update -n auto to run tests in parallel, which deletes snapshots

Screenshot of steps steps to reproduce

System information

Name Version
python 3.7.12
pip 21.3.1
syrupy 1.7.3
pytest-xdist 2.5.0
pytest 6.2.5
MacBook Pro 2016 MacOS Big Sur 11.6

piplist.txt requirements.txt Full code/minimum example: codebase.zip

RonnyPfannschmidt commented 2 years ago

duplicate of https://github.com/tophat/syrupy/issues/535