Fix build issues with python 3.8 and mock 3.0

This commit is contained in:
Julien Enselme 2019-08-01 22:13:11 +02:00
parent 2ae657fd9c
commit 2e9a0ca1f0
2 changed files with 52 additions and 1 deletions

46
fix-mock-python-3.8.patch Normal file
View File

@ -0,0 +1,46 @@
From b2683fdfc2fbd67dfc14bfc8e9d2c06530975397 Mon Sep 17 00:00:00 2001
From: Bruno Oliveira <bruno@esss.com.br>
Date: Fri, 3 May 2019 08:58:31 -0300
Subject: [PATCH] Fix tests due to new formatting in mock 3.0 and python 3.8
---
test_pytest_mock.py | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/test_pytest_mock.py b/test_pytest_mock.py
index 7bc38cb..562ff0c 100644
--- a/test_pytest_mock.py
+++ b/test_pytest_mock.py
@@ -10,11 +10,11 @@
# could not make some of the tests work on PyPy, patches are welcome!
skip_pypy = pytest.mark.skipif(
- platform.python_implementation() == "PyPy", reason="could not make work on pypy"
+ platform.python_implementation() == "PyPy", reason="could not make it work on pypy"
)
-# Python 3.8 changed the output formatting (bpo-35500).
-PY38 = sys.version_info >= (3, 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) or sys.version_info[0] == 2
@pytest.fixture
@@ -209,7 +209,7 @@ def test_repr_with_name(self, mocker):
def __test_failure_message(self, mocker, **kwargs):
expected_name = kwargs.get("name") or "mock"
- if PY38:
+ if NEW_FORMATTING:
msg = "expected call not found.\nExpected: {0}()\nActual: not called."
else:
msg = "Expected call: {0}()\nNot called"
@@ -620,7 +620,7 @@ def test(mocker):
"""
)
result = testdir.runpytest("-s")
- if PY38:
+ if NEW_FORMATTING:
expected_lines = [
"*AssertionError: expected call not found.",
"*Expected: mock('', bar=4)",

View File

@ -7,7 +7,7 @@ to worry about undoing patches at the end of a test.
Name: python-%{pypi_name}
Version: 1.10.4
Release: 3%{?dist}
Release: 4%{?dist}
Summary: Thin-wrapper around the mock package for easier use with py.test
License: MIT
@ -16,6 +16,8 @@ Source0: https://files.pythonhosted.org/packages/source/p/pytest-mock/pyt
BuildArch: noarch
# Fix tests expectations with latest pytest (4.6.3+)
Patch0: fix-expectations-pytest-4.6.3.patch
# Fix tests due to new formatting in mock 3.0 and python 3.8 (See https://github.com/pytest-dev/pytest-mock/commit/b3badafebedea3605c90eb22a68adff2885a8bb0)
Patch1: fix-mock-python-3.8.patch
%description
%{desc}
@ -92,6 +94,9 @@ PYTHONPATH="$(pwd)" py.test-%{python3_version} test_pytest_mock.py
%changelog
* Thu Aug 01 2019 Julien Enselme <jujens@jujens.eu> - 1.10.4-4
- Fix build issues with python 3.8 and mock 3.0
* Tue Jul 30 2019 Julien Enselme <jujens@jujens.eu> - 1.10.4-3
- Fix build issues with pytest 4.6.3