Skip to content

Comments

Fixed a bug where randomization logic was being incorrectly triggered (#31)#32

Merged
mark-adams merged 2 commits intomainfrom
fix-31
May 8, 2025
Merged

Fixed a bug where randomization logic was being incorrectly triggered (#31)#32
mark-adams merged 2 commits intomainfrom
fix-31

Conversation

@mark-adams
Copy link
Owner

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-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.

…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.
@mark-adams mark-adams merged commit 3c5eb78 into main May 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant