public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/python-pydantic] rawhide: Fix compatibility with pytest >= 9.1.0
Date: Mon, 29 Jun 2026 10:37:44 GMT	[thread overview]
Message-ID: <178272946465.1.16195178989381519952.rpms-python-pydantic-de01e962df5e@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/python-pydantic
            Branch : rawhide
            Commit : de01e962df5e71c5f7592fc24d4136bf5dddf18d
            Author : Tomáš Hrnčiar <thrnciar@redhat.com>
            Date   : 2026-06-29T09:25:19+02:00
            Stats  : +194/-0 in 3 file(s)
            URL    : https://src.fedoraproject.org/rpms/python-pydantic/c/de01e962df5e71c5f7592fc24d4136bf5dddf18d?branch=rawhide

            Log:
            Fix compatibility with pytest >= 9.1.0

Backport upstream commits 53706f8 and e3fe82e from PR #13357.

Assisted-by: Claude Opus 4.6

---
diff --git a/53706f8f95585f2ae0cee43c1df944956dd2a31f.patch b/53706f8f95585f2ae0cee43c1df944956dd2a31f.patch
new file mode 100644
index 0000000..22ccec7
--- /dev/null
+++ b/53706f8f95585f2ae0cee43c1df944956dd2a31f.patch
@@ -0,0 +1,102 @@
+From 53706f8f95585f2ae0cee43c1df944956dd2a31f Mon Sep 17 00:00:00 2001
+From: Colin Watson <cjwatson@debian.org>
+Date: Sun, 28 Jun 2026 15:49:47 +0100
+Subject: [PATCH] Don't parameterize tests using non-Collection iterables
+
+This is deprecated as of pytest 9.1; see
+https://docs.pytest.org/en/stable/deprecations.html#class-scoped-fixture-as-instance-method.
+---
+ pydantic-core/tests/test_docstrings.py | 4 ++--
+ tests/test_docs.py                     | 6 +++---
+ tests/test_utils.py                    | 4 ++--
+ tests/test_validators.py               | 2 +-
+ 4 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/pydantic-core/tests/test_docstrings.py b/pydantic-core/tests/test_docstrings.py
+index bfde27c3d0..d8057432d1 100644
+--- a/pydantic-core/tests/test_docstrings.py
++++ b/pydantic-core/tests/test_docstrings.py
+@@ -18,7 +18,7 @@ def find_examples(*args, **kwargs):
+ 
+ @pytest.mark.skipif(CodeExample is None or sys.platform not in {'linux', 'darwin'}, reason='Only on linux and macos')
+ @pytest.mark.parametrize(
+-    'example', find_examples(str(PYDANTIC_CORE_DIR / 'python/pydantic_core/core_schema.py')), ids=str
++    'example', list(find_examples(str(PYDANTIC_CORE_DIR / 'python/pydantic_core/core_schema.py'))), ids=str
+ )
+ @pytest.mark.thread_unsafe  # TODO investigate why pytest_examples seems to be thread unsafe here
+ def test_docstrings(example: CodeExample, eval_example: EvalExample):
+@@ -33,7 +33,7 @@ def test_docstrings(example: CodeExample, eval_example: EvalExample):
+ 
+ 
+ @pytest.mark.skipif(CodeExample is None or sys.platform not in {'linux', 'darwin'}, reason='Only on linux and macos')
+-@pytest.mark.parametrize('example', find_examples(str(PYDANTIC_CORE_DIR / 'README.md')), ids=str)
++@pytest.mark.parametrize('example', list(find_examples(str(PYDANTIC_CORE_DIR / 'README.md'))), ids=str)
+ @pytest.mark.thread_unsafe  # TODO investigate why pytest_examples seems to be thread unsafe here
+ def test_readme(example: CodeExample, eval_example: EvalExample):
+     eval_example.set_config(line_length=100, quotes='single')
+diff --git a/tests/test_docs.py b/tests/test_docs.py
+index 314dc8db6e..ac988769c2 100644
+--- a/tests/test_docs.py
++++ b/tests/test_docs.py
+@@ -171,7 +171,7 @@ def run_example(example: CodeExample, eval_example: EvalExample, mocker: Any) ->
+ @pytest.mark.thread_unsafe
+ @pytest.mark.filterwarnings('ignore:(parse_obj_as|schema_json_of|schema_of) is deprecated.*:DeprecationWarning')
+ @pytest.mark.skipif(bool(skip_reason), reason=skip_reason or 'not skipping')
+-@pytest.mark.parametrize('example', find_examples(str(SOURCES_ROOT), skip=sys.platform == 'win32'), ids=str)
++@pytest.mark.parametrize('example', list(find_examples(str(SOURCES_ROOT), skip=sys.platform == 'win32')), ids=str)
+ def test_docstrings_examples(example: CodeExample, eval_example: EvalExample, tmp_path: Path, mocker):
+     if str(example.path).startswith(str(SOURCES_ROOT / 'v1')):
+         pytest.skip('skip v1 examples')
+@@ -195,7 +195,7 @@ def set_cwd():
+ @pytest.mark.thread_unsafe
+ @pytest.mark.filterwarnings('ignore:(parse_obj_as|schema_json_of|schema_of) is deprecated.*:DeprecationWarning')
+ @pytest.mark.skipif(bool(skip_reason), reason=skip_reason or 'not skipping')
+-@pytest.mark.parametrize('example', find_examples(str(DOCS_ROOT), skip=sys.platform == 'win32'), ids=str)
++@pytest.mark.parametrize('example', list(find_examples(str(DOCS_ROOT), skip=sys.platform == 'win32')), ids=str)
+ def test_docs_examples(example: CodeExample, eval_example: EvalExample, tmp_path: Path, mocker):
+     global INDEX_MAIN
+     if example.path.name == 'index.md':
+@@ -215,7 +215,7 @@ def test_docs_examples(example: CodeExample, eval_example: EvalExample, tmp_path
+ @pytest.mark.skipif(bool(skip_reason), reason=skip_reason or 'not skipping')
+ @pytest.mark.skipif(sys.version_info >= (3, 13), reason='python-devtools does not yet support python 3.13')
+ @pytest.mark.parametrize(
+-    'example', find_examples(str(DOCS_ROOT / 'integrations/devtools.md'), skip=sys.platform == 'win32'), ids=str
++    'example', list(find_examples(str(DOCS_ROOT / 'integrations/devtools.md'), skip=sys.platform == 'win32')), ids=str
+ )
+ def test_docs_devtools_example(example: CodeExample, eval_example: EvalExample, tmp_path: Path):
+     from ansi2html import Ansi2HTMLConverter
+diff --git a/tests/test_utils.py b/tests/test_utils.py
+index f0b0b71d9e..3b8f2afefa 100644
+--- a/tests/test_utils.py
++++ b/tests/test_utils.py
+@@ -368,7 +368,7 @@ def test_smart_deepcopy_immutable_non_sequence(obj, mocker):
+     assert smart_deepcopy(obj) is deepcopy(obj) is obj
+ 
+ 
+-@pytest.mark.parametrize('empty_collection', (collection() for collection in BUILTIN_COLLECTIONS))
++@pytest.mark.parametrize('empty_collection', [collection() for collection in BUILTIN_COLLECTIONS])
+ def test_smart_deepcopy_empty_collection(empty_collection, mocker):
+     mocker.patch('pydantic._internal._utils.deepcopy', side_effect=RuntimeError)  # make sure deepcopy is not used
+     if not isinstance(empty_collection, (tuple, frozenset)):  # empty tuple or frozenset are always the same object
+@@ -377,7 +377,7 @@ def test_smart_deepcopy_empty_collection(empty_collection, mocker):
+ 
+ @pytest.mark.thread_unsafe(reason='Monkeypatching')
+ @pytest.mark.parametrize(
+-    'collection', (c.fromkeys((1,)) if issubclass(c, dict) else c((1,)) for c in BUILTIN_COLLECTIONS)
++    'collection', [c.fromkeys((1,)) if issubclass(c, dict) else c((1,)) for c in BUILTIN_COLLECTIONS]
+ )
+ def test_smart_deepcopy_collection(collection, mocker):
+     expected_value = object()
+diff --git a/tests/test_validators.py b/tests/test_validators.py
+index aaff88cf9e..4c53b64cfd 100644
+--- a/tests/test_validators.py
++++ b/tests/test_validators.py
+@@ -1600,7 +1600,7 @@ class Model(BaseModel):
+     assert dict(Model(x=1, y=1)) == {'x': 2, 'y': 2}
+ 
+ 
+-@pytest.mark.parametrize('validator_classmethod,root_validator_classmethod', product(*[[True, False]] * 2))
++@pytest.mark.parametrize('validator_classmethod,root_validator_classmethod', list(product(*[[True, False]] * 2)))
+ def test_root_validator_classmethod(validator_classmethod, root_validator_classmethod):
+     root_val_values = []
+ 

diff --git a/e3fe82eba47c78758a21d8413c52063fc105550e.patch b/e3fe82eba47c78758a21d8413c52063fc105550e.patch
new file mode 100644
index 0000000..bd59446
--- /dev/null
+++ b/e3fe82eba47c78758a21d8413c52063fc105550e.patch
@@ -0,0 +1,87 @@
+From e3fe82eba47c78758a21d8413c52063fc105550e Mon Sep 17 00:00:00 2001
+From: Colin Watson <cjwatson@debian.org>
+Date: Sun, 28 Jun 2026 15:52:39 +0100
+Subject: [PATCH] Fix use of pytest.warns(match=...)
+
+When called with a callable as a positional argument after the expected
+warning, `pytest.warns` either ignores the `match` keyword argument
+(pytest < 9.1.0) or passes it on to the provided callable (pytest >=
+9.1.0).  In the former case it was merely ineffective, masking an
+apparent bug (#13356), while in the latter case it results in
+`TypeError: ... got an unexpected keyword argument 'match'`.
+---
+ tests/test_deprecated_fields.py | 33 +++++++++++++++++++++++----------
+ 1 file changed, 23 insertions(+), 10 deletions(-)
+
+diff --git a/tests/test_deprecated_fields.py b/tests/test_deprecated_fields.py
+index b17f037ede2..a677a8301bc 100644
+--- a/tests/test_deprecated_fields.py
++++ b/tests/test_deprecated_fields.py
+@@ -25,7 +25,8 @@ class Model(BaseModel):
+ 
+     instance = Model(a=1, b=1, c=1)
+ 
+-    pytest.warns(DeprecationWarning, lambda: instance.a, match='^$')
++    with pytest.warns(DeprecationWarning, match='^$'):
++        instance.a
+ 
+     with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
+         b = instance.b
+@@ -52,9 +53,12 @@ class Model(BaseModel):
+ 
+     instance = Model(a=1)
+ 
+-    pytest.warns(DeprecationWarning, lambda: instance.a, match='^$')
+-    pytest.warns(DeprecationWarning, lambda: instance.b, match='^This is deprecated$')
+-    pytest.warns(DeprecationWarning, lambda: instance.c, match='^This is deprecated$')
++    with pytest.warns(DeprecationWarning, match='^$'):
++        instance.a
++    with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
++        instance.b
++    with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
++        instance.c
+ 
+ 
+ def test_deprecated_fields_field_validator():
+@@ -147,10 +151,17 @@ def p5(self) -> int:
+ 
+     instance = Model()
+ 
+-    pytest.warns(DeprecationWarning, lambda: instance.p1, match='^This is deprecated$')
+-    pytest.warns(DeprecationWarning, lambda: instance.p2, match='^This is deprecated$')
+-    pytest.warns(DeprecationWarning, lambda: instance.p4, match='^This is deprecated$')
+-    pytest.warns(DeprecationWarning, lambda: instance.p5, match='^This is deprecated$')
++    with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
++        instance.p1
++    # TODO: This should be match='^This is deprecated$' instead, but the
++    # overriding mechanism has apparently never worked:
++    # https://github.com/pydantic/pydantic/issues/13356
++    with pytest.warns(DeprecationWarning, match=r'^This is deprecated \(this message is overridden\)$'):
++        instance.p2
++    with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
++        instance.p4
++    with pytest.warns(DeprecationWarning, match='^This is deprecated$'):
++        instance.p5
+ 
+     with pytest.warns(DeprecationWarning, match='^$'):
+         p3 = instance.p3
+@@ -219,7 +230,8 @@ class Model(BaseModel):
+ 
+     instance = Model(a=1, b=1)
+ 
+-    pytest.warns(DeprecationWarning, lambda: instance.a, match='deprecated')
++    with pytest.warns(DeprecationWarning, match='deprecated'):
++        instance.a
+ 
+ 
+ def test_computed_field_deprecated_class_access() -> None:
+@@ -257,7 +269,8 @@ class Model(BaseModel):
+ 
+     m = Model()
+ 
+-    pytest.warns(DeprecationWarning, lambda: m.a, match='test')
++    with pytest.warns(DeprecationWarning, match='test'):
++        m.a
+ 
+ 
+ def test_deprecated_field_with_assignment() -> None:

diff --git a/python-pydantic.spec b/python-pydantic.spec
index c107e27..a9da529 100644
--- a/python-pydantic.spec
+++ b/python-pydantic.spec
@@ -11,6 +11,11 @@ License:        MIT
 URL:            https://github.com/pydantic/pydantic
 Source:         %{url}/archive/v%{version}/pydantic-%{version}.tar.gz
 
+# Fix test failures with pytest >= 9.1.0 (non-Collection iterables in parametrize)
+Patch:          https://github.com/pydantic/pydantic/commit/53706f8f95585f2ae0cee43c1df944956dd2a31f.patch
+# Fix use of pytest.warns(match=...) with pytest >= 9.1.0
+Patch:          https://github.com/pydantic/pydantic/commit/e3fe82eba47c78758a21d8413c52063fc105550e.patch
+
 BuildArch:      noarch
 
 BuildRequires:  tomcli

                 reply	other threads:[~2026-06-29 10:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178272946465.1.16195178989381519952.rpms-python-pydantic-de01e962df5e@fedoraproject.org \
    --to=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox