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
I'm working on a project which uses random generators to make sure tests which generate things like database entries don't create duplicates. I've combined this with pytest-randomly and "--randomly-seed=${GITHUB_RUN_ID}" --randomly-dont-reset-seed to have reproducible randomness: if the CI pipeline fails I can easily re-run the exact same thing locally. This is working fine, but when combined with pytest-xdist it looks like each worker is getting the same initial seed, and so the tests are back to generating duplicate values.
Is there some way to send a reproducible but different seed to each test when combined with python-xdist?
The text was updated successfully, but these errors were encountered:
pytest-randomly goes out of its way to ensure each process gets the same seed, otherwise tests won't be reproducible. The splitting between workers is non-deterministic since it relies on test runtime, which is noisy.
If you need to ensure different database records are created from different processes, you can use os.getpid() for a different number in each process. This could be used in a hash or as a seed to a local Random() instance (which pytest-randomly won't affect)
I'm working on a project which uses random generators to make sure tests which generate things like database entries don't create duplicates. I've combined this with pytest-randomly and
"--randomly-seed=${GITHUB_RUN_ID}" --randomly-dont-reset-seed
to have reproducible randomness: if the CI pipeline fails I can easily re-run the exact same thing locally. This is working fine, but when combined with pytest-xdist it looks like each worker is getting the same initial seed, and so the tests are back to generating duplicate values.Is there some way to send a reproducible but different seed to each test when combined with python-xdist?
The text was updated successfully, but these errors were encountered: