Python 3.14.0a6+ test fix

- Fixes: rhbz#2353145
This commit is contained in:
Miro Hrončok 2025-03-18 13:02:59 +01:00
commit 07d47763fe
2 changed files with 40 additions and 0 deletions

37
3500.patch Normal file
View file

@ -0,0 +1,37 @@
From e35abbef48a4cda2e376a7ff668961378f3c86cb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
Date: Tue, 18 Mar 2025 12:54:57 +0100
Subject: [PATCH] Tests: Adjust expected exception message for Python 3.14.0a6
E AssertionError: Regex pattern did not match.
E Regex: '3 cannot cast to typing.Union\\[str, int\\]'
E Input: '3 cannot cast to str | int'
Change caused likely by https://github.com/python/cpython/commit/dc6d66f44c0a25b69dfec7e4ffc4a6fa5e4feada
---
docs/changelog/3500.bugfix.rst | 2 ++
tests/config/loader/test_str_convert.py | 2 +-
2 files changed, 3 insertions(+), 1 deletion(-)
create mode 100644 docs/changelog/3500.bugfix.rst
diff --git a/docs/changelog/3500.bugfix.rst b/docs/changelog/3500.bugfix.rst
new file mode 100644
index 000000000..9df1cf05d
--- /dev/null
+++ b/docs/changelog/3500.bugfix.rst
@@ -0,0 +1,2 @@
+Make tox tests pass with Python 3.14.0a6
+- by :user:`hroncok`
diff --git a/tests/config/loader/test_str_convert.py b/tests/config/loader/test_str_convert.py
index 8540e2105..b06929f48 100644
--- a/tests/config/loader/test_str_convert.py
+++ b/tests/config/loader/test_str_convert.py
@@ -77,7 +77,7 @@ def test_str_convert_ok_py39(raw: str, value: Any, of_type: type[Any]) -> None:
[
("a", TypeVar, TypeError, r"a cannot cast to .*typing.TypeVar.*"),
("3", Literal["1", "2"], ValueError, r"3 must be one of \('1', '2'\)"),
- ("3", Union[str, int], TypeError, r"3 cannot cast to typing.Union\[str, int\]"),
+ ("3", Union[str, int], TypeError, r"3 cannot cast to (typing.Union\[str, int\]|str \| int)"),
("", Command, ValueError, r"attempting to parse '' into a command failed"),
],
)

View file

@ -35,6 +35,9 @@ Source: %{pypi_source tox}
# Adjust setuptools-version specific ifs to check for setuptools version rather than Python version.
Patch: fix-tests.patch
# Python 3.14.0a6+ test fix
Patch: https://github.com/tox-dev/tox/pull/3500.patch
BuildArch: noarch
BuildRequires: python3-devel