Skip to content

[v1.x] Pass a list to parametrize in test_docs_examples (pytest 9.1.0 compat)#2889

Merged
maxisbey merged 1 commit into
v1.xfrom
v1.x-pytest-9.1-parametrize
Jun 16, 2026
Merged

[v1.x] Pass a list to parametrize in test_docs_examples (pytest 9.1.0 compat)#2889
maxisbey merged 1 commit into
v1.xfrom
v1.x-pytest-9.1-parametrize

Conversation

@maxisbey

Copy link
Copy Markdown
Contributor

pytest 9.1.0 deprecates passing a non-Collection iterable (e.g. a generator) to pytest.mark.parametrize, raising PytestRemovedIn10Warning. With filterwarnings = ["error"] this fails collection on the highest-resolution CI lanes (all lowest-direct lanes pass since they pin an older pytest).

pytest_examples.find_examples() returns a generator; materialize it as a list. This is the fix pytest's own message recommends ("Please convert to a list or tuple").

Test-infrastructure only; no change to shipped code. Unblocks the v1.28.0 publish run.

The same change will be needed on main.

AI Disclaimer

pytest 9.1.0 deprecates passing a non-Collection iterable (e.g. a generator)
to pytest.mark.parametrize, raising PytestRemovedIn10Warning. With
filterwarnings = ["error"] this fails collection on the highest-resolution
CI lanes. find_examples() returns a generator; materialize it as a list.
@maxisbey maxisbey marked this pull request as ready for review June 16, 2026 21:27

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — straightforward pytest 9.1.0 compat fix, materializing the find_examples() generator into a list for parametrize.

Extended reasoning...

Overview

This PR changes a single line in tests/test_examples.py, wrapping find_examples("README.md") in list(...) so the value passed to pytest.mark.parametrize is a materialized Collection rather than a generator. This addresses PytestRemovedIn10Warning in pytest 9.1.0, which under filterwarnings = ["error"] was failing test collection on the highest-resolution CI lanes.

Security risks

None. The change is confined to test infrastructure and does not touch any shipped code, auth, crypto, or permissions.

Level of scrutiny

Minimal scrutiny warranted. This is a mechanical, idiomatic fix that pytest's own deprecation message explicitly recommends ("convert to a list or tuple"). Generators are single-pass, and parametrize iterates the argument once during collection, so materializing to a list is semantically equivalent and strictly safer.

Other factors

No bugs were reported by the bug hunting system, no prior review comments exist on the timeline, and the diff is a single self-contained line with clear intent. The behavior of test_docs_examples is unchanged.

@maxisbey maxisbey enabled auto-merge (squash) June 16, 2026 21:28
@maxisbey maxisbey merged commit 32d3290 into v1.x Jun 16, 2026
48 checks passed
@maxisbey maxisbey deleted the v1.x-pytest-9.1-parametrize branch June 16, 2026 21:29
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.

3 participants