From 150b6e22f9ce139bf6a01a2b8870a66065187090 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Sun, 28 Jan 2024 16:49:37 -0500 Subject: [PATCH] Fix build with Python 3.12.1 Python 3.11.7 and 3.12.1 tweaked the format of the error message. https://github.com/pytest-dev/pytest-mock/pull/404 --- 0001-Update-expected-message.patch | 37 ++++++++++++++++++++++++++++++ python-pytest-mock.spec | 3 +++ 2 files changed, 40 insertions(+) create mode 100644 0001-Update-expected-message.patch diff --git a/0001-Update-expected-message.patch b/0001-Update-expected-message.patch new file mode 100644 index 0000000..af27b8c --- /dev/null +++ b/0001-Update-expected-message.patch @@ -0,0 +1,37 @@ +From 6da5b0506d6378a8dbe5ae314d5134e6868aeabd Mon Sep 17 00:00:00 2001 +From: danigm +Date: Wed, 20 Dec 2023 16:02:13 +0100 +Subject: [PATCH] Update expected message to match python 3.11.7 (#404) + +https://github.com/python/cpython/issues/111019 + +Fixes #401. +Closes #403. +--- + tests/test_pytest_mock.py | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/tests/test_pytest_mock.py b/tests/test_pytest_mock.py +index c185f2a..01534a4 100644 +--- a/tests/test_pytest_mock.py ++++ b/tests/test_pytest_mock.py +@@ -25,6 +25,8 @@ + + # Python 3.8 changed the output formatting (bpo-35500), which has been ported to mock 3.0 + NEW_FORMATTING = sys.version_info >= (3, 8) ++# Python 3.11.7 changed the output formatting, https://github.com/python/cpython/issues/111019 ++NEWEST_FORMATTING = sys.version_info >= (3, 11, 7) + + if sys.version_info[:2] >= (3, 8): + from unittest.mock import AsyncMock +@@ -240,7 +242,9 @@ def test_repr_with_name(self, mocker: MockerFixture) -> None: + + def __test_failure_message(self, mocker: MockerFixture, **kwargs: Any) -> None: + expected_name = kwargs.get("name") or "mock" +- if NEW_FORMATTING: ++ if NEWEST_FORMATTING: ++ msg = "expected call not found.\nExpected: {0}()\n Actual: not called." ++ elif NEW_FORMATTING: + msg = "expected call not found.\nExpected: {0}()\nActual: not called." + else: + msg = "Expected call: {0}()\nNot called" diff --git a/python-pytest-mock.spec b/python-pytest-mock.spec index ca6e6d6..547cbd4 100644 --- a/python-pytest-mock.spec +++ b/python-pytest-mock.spec @@ -9,6 +9,9 @@ Summary: Thin-wrapper around the mock package for easier use with py.test License: MIT URL: https://github.com/pytest-dev/pytest-mock/ Source0: %{pypi_source} +# https://github.com/pytest-dev/pytest-mock/pull/404 +Patch0: 0001-Update-expected-message.patch + BuildArch: noarch %description