Wrap product() in list() where passed to parametrize#380
Merged
Conversation
test_eq_and_or_with_non_mapping and test_putall_matches_bulk_put pass an itertools.product object directly to @pytest.mark.parametrize. product returns a one-shot iterator, not a Collection. pytest 9.1 emits PytestRemovedIn10Warning for non-Collection iterables passed to parametrize, and pytest 10 removes support entirely, so collection of the whole test module will error once pytest is upgraded. Materialize the argvalues with list(), matching the existing list(powerset(product(...))) usage in this module. No behavioral change to the parametrization today; this only makes the argvalues a concrete Collection so the tests keep collecting under pytest >= 10.
Contributor
Benchmark report✅ No threshold-triggering regressions detected.
This benchmark check is informational and does not block merging. |
Owner
|
Thanks for the contribution! |
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.
What
Two tests pass an
itertools.productobject directly to@pytest.mark.parametrize:tests/test_bidict.py::test_eq_and_or_with_non_mappingtests/test_bidict.py::test_putall_matches_bulk_putproduct(...)returns a one-shot iterator, not aCollection. Thischange wraps both in
list()so the argvalues are a concreteCollection.Why
Starting with pytest 9.1, passing a non-
Collectioniterable toparametrizeraisesPytestRemovedIn10Warning, and pytest 10 removessupport entirely — at which point collecting
tests/test_bidict.pywill fail. See the pytest deprecation note:
https://docs.pytest.org/en/stable/deprecations.html#parametrize-iterators
Today (pytest 8.x/9.x) the suite still collects, but the run already
emits the warning:
Reproduce (deterministic)
Promote the warning to an error exactly as pytest 10 will:
Before / after
product(...))list(product(...)))pytest -W error::pytest.PytestRemovedIn10WarningpytestrunPytestRemovedIn10WarningNotes
materializes the argvalues into a concrete
Collection.list(powerset(product(ks, vs)))idiom alreadyused in this module.
CHANGELOG.rstentry: this is a test-tooling-only forward-compatfix with no user-facing change, consistent with recent bug-fix PRs
(Fix TypeError when comparing OrderedBidict keys() with items() or vice versa #376, Fix _dedup no-op detection for non-reflexive-equality keys/values (e.g. NaN) #377) which touched only source + tests.
114 passed.ruff checkclean on the changed file.