public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/python-setuptools] rawhide: Fix test collection error with pytest >= 9.1
@ 2026-07-03 15:38
0 siblings, 0 replies; only message in thread
From: @ 2026-07-03 15:38 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/python-setuptools
Branch : rawhide
Commit : 5ac47fa7b2f7674ec02df21f587b465e79c486fb
Author : Tomáš Hrnčiar <thrnciar@redhat.com>
Date : 2026-06-29T07:57:54+00:00
Stats : +242/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/python-setuptools/c/5ac47fa7b2f7674ec02df21f587b465e79c486fb?branch=rawhide
Log:
Fix test collection error with pytest >= 9.1
---
diff --git a/5244.patch b/5244.patch
new file mode 100644
index 0000000..bafdadf
--- /dev/null
+++ b/5244.patch
@@ -0,0 +1,239 @@
+From cad2e714081a5502f80436c6f936e9101ed42c0f Mon Sep 17 00:00:00 2001
+From: "Jason R. Coombs" <jaraco@jaraco.com>
+Date: Sat, 27 Jun 2026 17:19:44 -0400
+Subject: [PATCH 1/4] Materialize product() for parametrize
+
+A one-shot iterator (itertools.product) passed to @pytest.mark.parametrize
+gets exhausted after the first of this class' test methods collects, so the
+rest are silently skipped. pytest 9.1 deprecates this (pytest-dev/pytest#13409,
+PytestRemovedIn10Warning), turning it into a collection error. Wrap it in
+list() so the values can be reused.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+---
+ setuptools/tests/test_config_discovery.py | 12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py
+index b5df8203cd..15ddebce1a 100644
+--- a/setuptools/tests/test_config_discovery.py
++++ b/setuptools/tests/test_config_discovery.py
+@@ -162,10 +162,14 @@ def test_project(self, tmp_path, circumstance):
+
+ @pytest.mark.parametrize(
+ ("config_file", "param", "circumstance"),
+- product(
+- ["setup.cfg", "setup.py", "pyproject.toml"],
+- ["packages", "py_modules"],
+- FILES.keys(),
++ # ``list`` because a one-shot iterator gets exhausted across this
++ # class' test methods; deprecated in pytest 9.1 (pytest-dev/pytest#13409).
++ list(
++ product(
++ ["setup.cfg", "setup.py", "pyproject.toml"],
++ ["packages", "py_modules"],
++ FILES.keys(),
++ )
+ ),
+ )
+ def test_purposefully_empty(self, tmp_path, config_file, param, circumstance):
+
+From a6bbbb9aff9a8c1b82c44746d9cba5624403660a Mon Sep 17 00:00:00 2001
+From: "Jason R. Coombs" <jaraco@jaraco.com>
+Date: Sun, 28 Jun 2026 15:41:18 -0400
+Subject: [PATCH 2/4] Encapsulate eager product as greedy_product helper
+
+Replace the inline list(product(...)) with a module-level
+greedy_product = compose(list, product), documenting the pytest 9.1
+re-iterable-Collection requirement (pytest-dev/pytest#13409) as its docstring.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+---
+ setuptools/tests/test_config_discovery.py | 23 +++++++++++++++--------
+ 1 file changed, 15 insertions(+), 8 deletions(-)
+
+diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py
+index 15ddebce1a..97ce8669b8 100644
+--- a/setuptools/tests/test_config_discovery.py
++++ b/setuptools/tests/test_config_discovery.py
+@@ -6,6 +6,7 @@
+
+ import jaraco.path
+ import pytest
++from jaraco.functools import compose
+ from path import Path
+
+ import setuptools # noqa: F401 # force distutils.core to be patched
+@@ -20,6 +21,16 @@
+
+ import distutils.core
+
++greedy_product = compose(list, product)
++"""
++``itertools.product`` rendered eager (a list rather than a one-shot iterator).
++
++``@pytest.mark.parametrize`` needs a re-iterable Collection for ``argvalues``:
++a bare iterator gets exhausted after the first of a class' test methods is
++collected, silently skipping the rest. Deprecated in pytest 9.1, raising
++``PytestRemovedIn10Warning`` (pytest-dev/pytest#13409).
++"""
++
+
+ class TestFindParentPackage:
+ def test_single_package(self, tmp_path):
+@@ -162,14 +173,10 @@ def test_project(self, tmp_path, circumstance):
+
+ @pytest.mark.parametrize(
+ ("config_file", "param", "circumstance"),
+- # ``list`` because a one-shot iterator gets exhausted across this
+- # class' test methods; deprecated in pytest 9.1 (pytest-dev/pytest#13409).
+- list(
+- product(
+- ["setup.cfg", "setup.py", "pyproject.toml"],
+- ["packages", "py_modules"],
+- FILES.keys(),
+- )
++ greedy_product(
++ ["setup.cfg", "setup.py", "pyproject.toml"],
++ ["packages", "py_modules"],
++ FILES.keys(),
+ ),
+ )
+ def test_purposefully_empty(self, tmp_path, config_file, param, circumstance):
+
+From c5f158ac63147898f62e40fa6ea8287bbd679392 Mon Sep 17 00:00:00 2001
+From: "Jason R. Coombs" <jaraco@jaraco.com>
+Date: Sun, 28 Jun 2026 15:54:55 -0400
+Subject: [PATCH 3/4] Make greedy_product a typed function
+
+compose(list, product) can't be typed: product is an overloaded callable, and
+passing it by value to compose's Callable[_P, _R] parameter collapses it to its
+first overload (single iterable), so mypy types the result as a one-arg function
+(var-annotated / arg-type / too-many-arguments errors).
+
+Define greedy_product as a function that *calls* product(*iterables) instead, so
+the variadic overload resolves normally and the helper types cleanly.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+---
+ setuptools/tests/test_config_discovery.py | 20 +++++++++++---------
+ 1 file changed, 11 insertions(+), 9 deletions(-)
+
+diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py
+index 97ce8669b8..47cde7f220 100644
+--- a/setuptools/tests/test_config_discovery.py
++++ b/setuptools/tests/test_config_discovery.py
+@@ -1,12 +1,12 @@
+ import os
+ import sys
++from collections.abc import Iterable
+ from configparser import ConfigParser
+ from itertools import product
+ from typing import cast
+
+ import jaraco.path
+ import pytest
+-from jaraco.functools import compose
+ from path import Path
+
+ import setuptools # noqa: F401 # force distutils.core to be patched
+@@ -21,15 +21,17 @@
+
+ import distutils.core
+
+-greedy_product = compose(list, product)
+-"""
+-``itertools.product`` rendered eager (a list rather than a one-shot iterator).
+
+-``@pytest.mark.parametrize`` needs a re-iterable Collection for ``argvalues``:
+-a bare iterator gets exhausted after the first of a class' test methods is
+-collected, silently skipping the rest. Deprecated in pytest 9.1, raising
+-``PytestRemovedIn10Warning`` (pytest-dev/pytest#13409).
+-"""
++def greedy_product(*iterables: Iterable[object]) -> list[tuple[object, ...]]:
++ """
++ ``itertools.product`` rendered eager (a list rather than a one-shot iterator).
++
++ ``@pytest.mark.parametrize`` needs a re-iterable Collection for ``argvalues``:
++ a bare iterator gets exhausted after the first of a class' test methods is
++ collected, silently skipping the rest. Deprecated in pytest 9.1, raising
++ ``PytestRemovedIn10Warning`` (pytest-dev/pytest#13409).
++ """
++ return list(product(*iterables))
+
+
+ class TestFindParentPackage:
+
+From ee52871601dd18c33f317e6856ae465d5fbc1d59 Mon Sep 17 00:00:00 2001
+From: "Jason R. Coombs" <jaraco@jaraco.com>
+Date: Sun, 28 Jun 2026 16:17:21 -0400
+Subject: [PATCH 4/4] Restore compose(list, product) with linked type: ignores
+
+Revert greedy_product to the concise compose(list, product) form. mypy can't
+type it (product is overloaded; passing it by value through compose's ParamSpec
+collapses it to its first overload, python/mypy#13540), so suppress the
+resulting var-annotated/arg-type/call-arg errors with type: ignore comments that
+cite the upstream issue. warn_unused_ignores is disabled in mypy.ini, so these
+are safe.
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+---
+ setuptools/tests/test_config_discovery.py | 24 ++++++++++++-----------
+ 1 file changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/setuptools/tests/test_config_discovery.py b/setuptools/tests/test_config_discovery.py
+index 47cde7f220..233a5bf82e 100644
+--- a/setuptools/tests/test_config_discovery.py
++++ b/setuptools/tests/test_config_discovery.py
+@@ -1,12 +1,12 @@
+ import os
+ import sys
+-from collections.abc import Iterable
+ from configparser import ConfigParser
+ from itertools import product
+ from typing import cast
+
+ import jaraco.path
+ import pytest
++from jaraco.functools import compose
+ from path import Path
+
+ import setuptools # noqa: F401 # force distutils.core to be patched
+@@ -21,17 +21,19 @@
+
+ import distutils.core
+
++greedy_product = compose(list, product) # type: ignore[var-annotated,arg-type] # python/mypy#13540
++"""
++``itertools.product`` rendered eager (a list rather than a one-shot iterator).
+
+-def greedy_product(*iterables: Iterable[object]) -> list[tuple[object, ...]]:
+- """
+- ``itertools.product`` rendered eager (a list rather than a one-shot iterator).
++``@pytest.mark.parametrize`` needs a re-iterable Collection for ``argvalues``:
++a bare iterator gets exhausted after the first of a class' test methods is
++collected, silently skipping the rest. Deprecated in pytest 9.1, raising
++``PytestRemovedIn10Warning`` (pytest-dev/pytest#13409).
+
+- ``@pytest.mark.parametrize`` needs a re-iterable Collection for ``argvalues``:
+- a bare iterator gets exhausted after the first of a class' test methods is
+- collected, silently skipping the rest. Deprecated in pytest 9.1, raising
+- ``PytestRemovedIn10Warning`` (pytest-dev/pytest#13409).
+- """
+- return list(product(*iterables))
++The ``type: ignore`` comments work around python/mypy#13540: mypy collapses the
++overloaded ``product`` to its first overload when it is passed by value through
++``compose``'s ParamSpec, mis-typing the result as a single-argument callable.
++"""
+
+
+ class TestFindParentPackage:
+@@ -175,7 +177,7 @@ def test_project(self, tmp_path, circumstance):
+
+ @pytest.mark.parametrize(
+ ("config_file", "param", "circumstance"),
+- greedy_product(
++ greedy_product( # type: ignore[call-arg] # python/mypy#13540
+ ["setup.cfg", "setup.py", "pyproject.toml"],
+ ["packages", "py_modules"],
+ FILES.keys(),
diff --git a/python-setuptools.spec b/python-setuptools.spec
index fb34c98..fed0eee 100644
--- a/python-setuptools.spec
+++ b/python-setuptools.spec
@@ -38,6 +38,9 @@ Patch: Remove-optional-or-unpackaged-test-deps.patch
# adjust it, but only when $RPM_BUILD_ROOT is set
Patch: Adjust-the-setup.py-install-deprecation-message.patch
+# Fix test collection error with pytest >= 9.1 (non-Collection iterable in parametrize)
+Patch: https://github.com/pypa/setuptools/pull/5244.patch
+
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-07-03 15:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-03 15:38 [rpms/python-setuptools] rawhide: Fix test collection error with pytest >= 9.1
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox