From 50f0b6c6bcc3633f62ae5e3ae9ca9a7c2b8a3767 Mon Sep 17 00:00:00 2001 From: Julien Enselme Date: Sat, 1 Oct 2016 17:04:35 +0200 Subject: [PATCH] Add patch to fix tests with pytest3 --- fix-for-pytest3.patch | 21 +++++++++++++++++++++ python-pytest-mock.spec | 8 +++++++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 fix-for-pytest3.patch diff --git a/fix-for-pytest3.patch b/fix-for-pytest3.patch new file mode 100644 index 0000000..0b243f8 --- /dev/null +++ b/fix-for-pytest3.patch @@ -0,0 +1,21 @@ +diff --git a/test_pytest_mock.py b/test_pytest_mock.py +index 1e47d0e..e54649a 100644 +--- a/test_pytest_mock.py ++++ b/test_pytest_mock.py +@@ -176,7 +176,7 @@ def __test_failure_message(self, mocker, **kwargs): + stub = mocker.stub(**kwargs) + with pytest.raises(AssertionError) as exc_info: + stub.assert_called_with() +- assert exc_info.value.msg == expected_message ++ assert str(exc_info.value) == expected_message + + def test_failure_message_with_no_name(self, mocker): + self.__test_failure_message(mocker) +@@ -352,7 +352,7 @@ def assert_argument_introspection(left, right): + # test was run by examining sys.argv + verbose = any(a.startswith('-v') for a in sys.argv) + expected = '\n '.join(util._compare_eq_iterable(left, right, verbose)) +- assert expected in e.msg ++ assert expected in str(e) + else: + raise AssertionError("DID NOT RAISE") diff --git a/python-pytest-mock.spec b/python-pytest-mock.spec index 4343b26..37538fa 100644 --- a/python-pytest-mock.spec +++ b/python-pytest-mock.spec @@ -7,12 +7,14 @@ to worry about undoing patches at the end of a test. Name: python-%{pypi_name} Version: 1.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Thin-wrapper around the mock package for easier use with py.test License: MIT URL: https://pypi.python.org/pypi/pytest-mock Source0: https://pypi.python.org/packages/30/11/a5a8009eff04bc15c37e2f8e33d8ed99adf828ec8f551fb31d99f6c73b5b/pytest-mock-1.2.zip +# From: https://github.com/pytest-dev/pytest-mock/pull/63 +Patch0: fix-for-pytest3.patch BuildArch: noarch %description @@ -48,6 +50,7 @@ Requires: python3-pytest >= 2.7 %prep %setup -qn %{pypi_name}-%{version} rm -rf *.egg-info +patch -p1 --binary < %{PATCH0} # Correct end of line encoding for README sed -i 's/\r$//' README.rst @@ -84,6 +87,9 @@ PYTHONPATH="$(pwd)" py.test-%{python3_version} test_pytest_mock.py %changelog +* Sat Oct 01 2016 Julien Enselme - 1.2-2 +- Add patch to fix tests with pytest3 + * Sun Sep 18 2016 Julien Enselme - 1.2-1 - Update to 1.2