Fixed a bug where randomization logic was being incorrectly triggered (#31)#32
Merged
mark-adams merged 2 commits intomainfrom May 8, 2025
Merged
Fixed a bug where randomization logic was being incorrectly triggered (#31)#32mark-adams merged 2 commits intomainfrom
mark-adams merged 2 commits intomainfrom
Conversation
…31) Previously, a call to config.getoption() passed in a default argument of 'False'. Unfortunately, per [the docs](https://github.com/pytest-dev/pytest/blob/89b84cb56295c46e1d8834b599e858bc65c15a5b/src/_pytest/config/__init__.py#L1733-L1734) the default argument is only for if the argument isn't declared, not if the argument is not present. As a result, the absence of `--test-group-random-seed` would always result in a value of `None` which is not `False` so it would trigger the randomization logic with a seed of `None`. When the seed is `None`, a random seed is chosen so each xdist process winds up coming up with a different list. The fix is simple: check to see if the seed is not `None` in order to trigger the activation logic.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, a call to config.getoption() passed in a default argument of 'False'. Unfortunately, per the docs the default argument is only for if the argument isn't declared, not if the argument is not present.
As a result, the absence of
--test-group-random-seedwould always result in a value ofNonewhich is notFalseso it would trigger the randomization logic with a seed ofNone. When the seed isNone, a random seed is chosen so each xdist process winds up coming up with a different list.The fix is simple: check to see if the seed is not
Nonein order to trigger the activation logic.