Skip to content

Convert parametrize argvalues to lists for pytest 10 - #839

Open
faisalsardi-dev wants to merge 1 commit into
hynek:mainfrom
faisalsardi-dev:pytest-parametrize-list
Open

Convert parametrize argvalues to lists for pytest 10#839
faisalsardi-dev wants to merge 1 commit into
hynek:mainfrom
faisalsardi-dev:pytest-parametrize-list

Conversation

@faisalsardi-dev

Copy link
Copy Markdown

Summary

What:

Two warnings show up when running python -Im pytest. They're about a pytest 10 deprecation: iterators passed to parametrize won't be accepted anymore.

How:

Wrap the itertools.product() calls passed to pytest.mark.parametrize() in list().

Why:

product() returns a one-shot iterator. pytest 9 accepts it but emits PytestRemovedIn10Warning, and pytest 10 will require a Collection.

Converting to a list or tuple is the fix documented by pytest:
https://docs.pytest.org/en/stable/deprecations.html#parametrize-iterators

Same 948 tests collected before and after, so the parametrization didn't change.

Most of the diff is re-indentation caused by the added list() wrapper. git diff -w shows the actual change is two lines per call site.

Verification:

Running python -Im pytest shows the two PytestRemovedIn10Warnings are gone, reducing the warning count from 2 to 0.

I skipped the changelog since this only touches tests.

Pull Request Checklist

  • I acknowledge this project's AI policy.
  • This pull request is not from my main branch.
  • There's tests for all new and changed code.
  • New APIs are added to our typing tests in api.py.
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
      • The next version is the second number in the current release + 1. The first number represents the current year. So if the current version on PyPI is 26.1.0, the next version is gonna be 26.2.0. If the next version is the first in the new year, it'll be 27.1.0.
  • Documentation in .rst and .md files is written using semantic newlines.
  • Changes (and possible deprecations) are documented in the changelog.

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