Skip to content

Pass a list to parametrize in test_docs_examples (pytest 9.1.0 compat)#2890

Merged
maxisbey merged 1 commit into
mainfrom
main-pytest-9.1-parametrize
Jun 16, 2026
Merged

Pass a list to parametrize in test_docs_examples (pytest 9.1.0 compat)#2890
maxisbey merged 1 commit into
mainfrom
main-pytest-9.1-parametrize

Conversation

@maxisbey

@maxisbey maxisbey commented Jun 16, 2026

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. pytest_examples.find_examples() returns a generator; materialize it as a list.

Same fix as #2889 on v1.x. main's CI matrix uses locked resolution (pytest 8.4.2) so this is not currently failing there, but it future-proofs against the next pytest bump in uv.lock. Verified locally that tests/test_examples.py collects clean and all 45 tests pass under pytest 9.1.0 with -W error.

The uv.lock bump to 9.1.0 is deliberately left for a separate PR.

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. find_examples() returns a
generator; materialize it as a list.

Same fix as #2889 on v1.x. main's CI matrix uses locked resolution so this
is not currently failing there, but it future-proofs against a pytest bump.
@maxisbey maxisbey marked this pull request as ready for review June 16, 2026 22:08

@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 one-line test fix wrapping find_examples() in list() for pytest 9.1.0 parametrize compatibility.

Extended reasoning...

Overview

This PR changes a single line in tests/test_examples.py, wrapping find_examples("README.v2.md") in list(...) so that pytest.mark.parametrize receives a materialized Collection rather than a generator. This is test-only code with no impact on the library or any production code path.

Security risks

None. The change touches only test collection/parametrization and introduces no new inputs, network, auth, or data-handling logic.

Level of scrutiny

Low. This is a mechanical, well-understood fix: pytest 9.1.0 deprecates passing non-Collection iterables to parametrize, and the canonical remedy is to materialize the generator into a list. The PR description notes it mirrors #2889 on v1.x and was verified locally (45 tests pass under pytest 9.1.0 with -W error).

Other factors

No bugs were reported by the bug hunting system, the diff is a single line, intent is clear, and there is no reviewer discussion outstanding. ids=str behavior is unchanged. Safe to approve without human review.

@maxisbey maxisbey enabled auto-merge (squash) June 16, 2026 22:10
@maxisbey maxisbey merged commit df81c06 into main Jun 16, 2026
32 checks passed
@maxisbey maxisbey deleted the main-pytest-9.1-parametrize branch June 16, 2026 22:15
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.

2 participants