From b1ce010d420033fd20f0207053747105cc63e586cc12f8e1cf9eb4ddbe3c122d Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Wed, 20 Dec 2023 12:44:07 +0000 Subject: [PATCH] Accepting request 1134208 from home:dgarcia:branches:devel:languages:python:Factory - Fix tests with python 3.11.7 - Add patch fix-tests-python3117.patch gh#pytest-dev/pytest-mock#403 OBS-URL: https://build.opensuse.org/request/show/1134208 OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-mock?expand=0&rev=40 --- fix-tests-python3117.patch | 44 ++++++++++++++++++++++++++++++++++++++ python-pytest-mock.changes | 6 ++++++ python-pytest-mock.spec | 2 ++ 3 files changed, 52 insertions(+) create mode 100644 fix-tests-python3117.patch diff --git a/fix-tests-python3117.patch b/fix-tests-python3117.patch new file mode 100644 index 0000000..c1b97db --- /dev/null +++ b/fix-tests-python3117.patch @@ -0,0 +1,44 @@ +From 8480bb6d0500f933be039cfec65e04157e6ecffe Mon Sep 17 00:00:00 2001 +From: Bruno Oliveira +Date: Tue, 19 Dec 2023 08:24:23 -0300 +Subject: [PATCH 1/2] Fix tests for Python 3.11 and 3.12 + +Fixes #401. +--- + tests/test_pytest_mock.py | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +Index: pytest-mock-3.12.0/tests/test_pytest_mock.py +=================================================================== +--- pytest-mock-3.12.0.orig/tests/test_pytest_mock.py ++++ pytest-mock-3.12.0/tests/test_pytest_mock.py +@@ -25,6 +25,7 @@ skip_pypy = pytest.mark.skipif( + + # Python 3.8 changed the output formatting (bpo-35500), which has been ported to mock 3.0 + NEW_FORMATTING = sys.version_info >= (3, 8) ++NEWEST_FORMATTING = sys.version_info >= (3, 11, 7) + + if sys.version_info[:2] >= (3, 8): + from unittest.mock import AsyncMock +@@ -240,15 +241,18 @@ class TestMockerStub: + + 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" + expected_message = msg.format(expected_name) + stub = mocker.stub(**kwargs) +- with pytest.raises(AssertionError) as exc_info: ++ with pytest.raises( ++ AssertionError, match=re.escape(expected_message) ++ ) as exc_info: + stub.assert_called_with() +- assert str(exc_info.value) == expected_message + + def test_failure_message_with_no_name(self, mocker: MagicMock) -> None: + self.__test_failure_message(mocker) diff --git a/python-pytest-mock.changes b/python-pytest-mock.changes index b288175..2bed778 100644 --- a/python-pytest-mock.changes +++ b/python-pytest-mock.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Wed Dec 20 12:28:16 UTC 2023 - Daniel Garcia + +- Fix tests with python 3.11.7 +- Add patch fix-tests-python3117.patch gh#pytest-dev/pytest-mock#403 + ------------------------------------------------------------------- Tue Nov 7 19:35:58 UTC 2023 - Dirk Müller diff --git a/python-pytest-mock.spec b/python-pytest-mock.spec index 66beeee..4d9d05e 100644 --- a/python-pytest-mock.spec +++ b/python-pytest-mock.spec @@ -24,6 +24,8 @@ Summary: Thin-wrapper around the mock package for easier use with pytest License: MIT URL: https://github.com/pytest-dev/pytest-mock Source: https://files.pythonhosted.org/packages/source/p/pytest-mock/pytest-mock-%{version}.tar.gz +# PATCH-FIX-UPSTREAM: fix-tests-python3117.patch gh#pytest-dev/pytest-mock#403 +Patch0: fix-tests-python3117.patch BuildRequires: %{python_module base >= 3.8} BuildRequires: %{python_module pytest >= 5} BuildRequires: %{python_module pytest-asyncio}