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
This commit is contained in:
parent
312a9e3b24
commit
b1ce010d42
44
fix-tests-python3117.patch
Normal file
44
fix-tests-python3117.patch
Normal file
@ -0,0 +1,44 @@
|
||||
From 8480bb6d0500f933be039cfec65e04157e6ecffe Mon Sep 17 00:00:00 2001
|
||||
From: Bruno Oliveira <nicoddemus@gmail.com>
|
||||
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)
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Dec 20 12:28:16 UTC 2023 - Daniel Garcia <daniel.garcia@suse.com>
|
||||
|
||||
- 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 <dmueller@suse.com>
|
||||
|
||||
|
@ -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}
|
||||
|
Loading…
Reference in New Issue
Block a user