Hello community,

here is the log from the commit of package python-pytest-mock for 
openSUSE:Factory checked in at 2020-01-16 18:13:39
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-mock (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-mock.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-mock"

Thu Jan 16 18:13:39 2020 rev:17 rq:761149 version:2.0.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-pytest-mock/python-pytest-mock.changes    
2019-12-11 12:00:14.280863697 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-mock.new.26092/python-pytest-mock.changes
 2020-01-16 18:13:42.940719412 +0100
@@ -1,0 +2,11 @@
+Mon Jan  6 13:11:42 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Update to 2.0.0:
+  * mocker.spy attributes for tracking returned values and raised
+    exceptions of its spied functions are now called spy_return
+    and spy_exception, instead of reusing the existing MagicMock
+    attributes return_value and side_effect.
+  * The deprecated mock alias to the mocker fixture has finally
+    been removed.
+
+-------------------------------------------------------------------

Old:
----
  pytest-mock-1.12.1.tar.gz

New:
----
  pytest-mock-2.0.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-mock.spec ++++++
--- /var/tmp/diff_new_pack.RcKLmn/_old  2020-01-16 18:13:43.612719792 +0100
+++ /var/tmp/diff_new_pack.RcKLmn/_new  2020-01-16 18:13:43.616719794 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pytest-mock
 #
-# Copyright (c) 2019 SUSE LLC
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -20,7 +20,7 @@
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
 %bcond_without python2
 Name:           python-pytest-mock
-Version:        1.12.1
+Version:        2.0.0
 Release:        0
 Summary:        Thin-wrapper around the mock package for easier use with pytest
 License:        MIT

++++++ pytest-mock-1.12.1.tar.gz -> pytest-mock-2.0.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/CHANGELOG.rst 
new/pytest-mock-2.0.0/CHANGELOG.rst
--- old/pytest-mock-1.12.1/CHANGELOG.rst        2019-11-20 23:07:32.000000000 
+0100
+++ new/pytest-mock-2.0.0/CHANGELOG.rst 2020-01-04 19:44:53.000000000 +0100
@@ -1,3 +1,29 @@
+2.0.0 (2020-01-04)
+------------------
+
+Breaking Changes
+++++++++++++++++
+
+* ``mocker.spy`` attributes for tracking returned values and raised exceptions 
of its spied functions
+  are now called ``spy_return`` and ``spy_exception``, instead of reusing the 
existing
+  ``MagicMock`` attributes ``return_value`` and ``side_effect``.
+
+  Version ``1.13`` introduced a serious regression: after a spied function 
using ``mocker.spy``
+  raises an exception, further calls to the spy will not call the spied 
function,
+  always raising the first exception instead: assigning to ``side_effect`` 
causes
+  ``unittest.mock`` to behave this way (`#175`_).
+
+* The deprecated ``mock`` alias to the ``mocker`` fixture has finally been 
removed.
+
+.. _#175: https://github.com/pytest-dev/pytest-mock/issues/175
+
+
+1.13.0 (2019-12-05)
+-------------------
+
+* The object returned by ``mocker.spy`` now also tracks any side effect
+  of the spied method/function.
+
 1.12.1 (2019-11-20)
 -------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/PKG-INFO 
new/pytest-mock-2.0.0/PKG-INFO
--- old/pytest-mock-1.12.1/PKG-INFO     2019-11-20 23:07:44.000000000 +0100
+++ new/pytest-mock-2.0.0/PKG-INFO      2020-01-04 19:44:56.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-mock
-Version: 1.12.1
+Version: 2.0.0
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
@@ -10,10 +10,8 @@
         pytest-mock
         ===========
         
-        This plugin installs a ``mocker`` fixture which is a thin-wrapper 
around the patching API
-        provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
-        but with the benefit of not having to worry about undoing patches at 
the end
-        of a test:
+        This plugin provides a ``mocker`` fixture which is a thin-wrapper 
around the patching API
+        provided by the `mock package <http://pypi.python.org/pypi/mock>`_:
         
         .. code-block:: python
         
@@ -31,6 +29,9 @@
                 os.remove.assert_called_once_with('file')
         
         
+        Besides undoing the mocking automatically after the end of the test, 
it also provides other
+        nice utilities such as ``spy`` and ``stub``, and uses pytest 
introspection when
+        comparing calls.
         
         |python| |version| |anaconda| |ci| |coverage| |black|
         
@@ -43,8 +44,8 @@
         .. |ci| image:: 
https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg
           :target: https://github.com/pytest-dev/pytest-mock/actions
         
-        .. |coverage| image:: 
http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg
-          :target: https://coveralls.io/r/pytest-dev/pytest-mock
+        .. |coverage| image:: 
https://coveralls.io/repos/github/pytest-dev/pytest-mock/badge.svg?branch=master
+          :target: 
https://coveralls.io/github/pytest-dev/pytest-mock?branch=master
         
         .. |python| image:: 
https://img.shields.io/pypi/pyversions/pytest-mock.svg
           :target: https://pypi.python.org/pypi/pytest-mock/
@@ -78,7 +79,7 @@
         * `mocker.stopall 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.stopall>`_
         * ``mocker.resetall()``: calls `reset_mock() 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.reset_mock>`_
 in all mocked objects up to this point.
         
-        These objects from the ``mock`` module are accessible directly from 
``mocker`` for convenience:
+        Also, as a convenience, these names from the ``mock`` module are 
accessible directly from ``mocker``:
         
         * `Mock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
         * `MagicMock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
@@ -93,30 +94,47 @@
         Spy
         ---
         
-        The spy acts exactly like the original method in all cases, except it 
allows use of ``mock``
-        features with it, like retrieving call count. It also works for class 
and static methods.
+        The ``mocker.spy`` object acts exactly like the original method in all 
cases, except the spy
+        also tracks method calls, return values and exceptions raised.
         
         .. code-block:: python
         
             def test_spy(mocker):
                 class Foo(object):
-                    def bar(self):
-                        return 42
+                    def bar(self, v):
+                        return v * 2
         
                 foo = Foo()
-                mocker.spy(foo, 'bar')
-                assert foo.bar() == 42
-                assert foo.bar.call_count == 1
+                spy = mocker.spy(foo, 'bar')
+                assert foo.bar(21) == 42
         
-        Since version ``1.11``, it is also possible to query the 
``return_value`` attribute
-        to observe what the spied function/method returned.
+                spy.assert_called_once_with(21)
+                assert spy.spy_return == 42
+        
+        The object returned by ``mocker.spy`` is a ``MagicMock`` object, so 
all standard checking functions
+        are available (like ``assert_called_once_with`` in the example above).
+        
+        In addition, spy objects contain two extra attributes:
+        
+        * ``spy_return``: contains the returned value of the spied function.
+        * ``spy_exception``: contain the last exception value raised by the 
spied function/method when
+          it was last called, or ``None`` if no exception was raised.
+        
+        ``mocker.spy`` also works for class and static methods.
+        
+        .. note::
+        
+            In versions earlier than ``2.0``, the attributes were called 
``return_value`` and
+            ``side_effect`` respectively, but due to incompatibilities with 
``unittest.mock``
+            they had to be renamed (see `#175`_ for details).
+        
+            .. _#175: https://github.com/pytest-dev/pytest-mock/issues/175
         
         Stub
         ----
         
-        
-        The stub is a mock object that accepts any arguments and is useful to 
test callbacks, for instance.
-        May be passed a name to be used by the constructed stub object in its 
repr (useful for debugging).
+        The stub is a mock object that accepts any arguments and is useful to 
test callbacks.
+        It may receive an optional name that is shown in its ``repr``, useful 
for debugging.
         
         .. code-block:: python
         
@@ -133,7 +151,6 @@
         Improved reporting of mock call assertion errors
         ------------------------------------------------
         
-        
         This plugin monkeypatches the mock library to improve pytest output 
for failures
         of mock call assertions like ``Mock.assert_called_with()`` by hiding 
internal traceback
         entries from the ``mock`` module.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/README.rst 
new/pytest-mock-2.0.0/README.rst
--- old/pytest-mock-1.12.1/README.rst   2019-11-20 23:07:32.000000000 +0100
+++ new/pytest-mock-2.0.0/README.rst    2020-01-04 19:44:53.000000000 +0100
@@ -2,10 +2,8 @@
 pytest-mock
 ===========
 
-This plugin installs a ``mocker`` fixture which is a thin-wrapper around the 
patching API
-provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
-but with the benefit of not having to worry about undoing patches at the end
-of a test:
+This plugin provides a ``mocker`` fixture which is a thin-wrapper around the 
patching API
+provided by the `mock package <http://pypi.python.org/pypi/mock>`_:
 
 .. code-block:: python
 
@@ -23,6 +21,9 @@
         os.remove.assert_called_once_with('file')
 
 
+Besides undoing the mocking automatically after the end of the test, it also 
provides other
+nice utilities such as ``spy`` and ``stub``, and uses pytest introspection when
+comparing calls.
 
 |python| |version| |anaconda| |ci| |coverage| |black|
 
@@ -35,8 +36,8 @@
 .. |ci| image:: 
https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg
   :target: https://github.com/pytest-dev/pytest-mock/actions
 
-.. |coverage| image:: 
http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg
-  :target: https://coveralls.io/r/pytest-dev/pytest-mock
+.. |coverage| image:: 
https://coveralls.io/repos/github/pytest-dev/pytest-mock/badge.svg?branch=master
+  :target: https://coveralls.io/github/pytest-dev/pytest-mock?branch=master
 
 .. |python| image:: https://img.shields.io/pypi/pyversions/pytest-mock.svg
   :target: https://pypi.python.org/pypi/pytest-mock/
@@ -70,7 +71,7 @@
 * `mocker.stopall 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.stopall>`_
 * ``mocker.resetall()``: calls `reset_mock() 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.reset_mock>`_
 in all mocked objects up to this point.
 
-These objects from the ``mock`` module are accessible directly from ``mocker`` 
for convenience:
+Also, as a convenience, these names from the ``mock`` module are accessible 
directly from ``mocker``:
 
 * `Mock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
 * `MagicMock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
@@ -85,30 +86,47 @@
 Spy
 ---
 
-The spy acts exactly like the original method in all cases, except it allows 
use of ``mock``
-features with it, like retrieving call count. It also works for class and 
static methods.
+The ``mocker.spy`` object acts exactly like the original method in all cases, 
except the spy
+also tracks method calls, return values and exceptions raised.
 
 .. code-block:: python
 
     def test_spy(mocker):
         class Foo(object):
-            def bar(self):
-                return 42
+            def bar(self, v):
+                return v * 2
 
         foo = Foo()
-        mocker.spy(foo, 'bar')
-        assert foo.bar() == 42
-        assert foo.bar.call_count == 1
+        spy = mocker.spy(foo, 'bar')
+        assert foo.bar(21) == 42
 
-Since version ``1.11``, it is also possible to query the ``return_value`` 
attribute
-to observe what the spied function/method returned.
+        spy.assert_called_once_with(21)
+        assert spy.spy_return == 42
+
+The object returned by ``mocker.spy`` is a ``MagicMock`` object, so all 
standard checking functions
+are available (like ``assert_called_once_with`` in the example above).
+
+In addition, spy objects contain two extra attributes:
+
+* ``spy_return``: contains the returned value of the spied function.
+* ``spy_exception``: contain the last exception value raised by the spied 
function/method when
+  it was last called, or ``None`` if no exception was raised.
+
+``mocker.spy`` also works for class and static methods.
+
+.. note::
+
+    In versions earlier than ``2.0``, the attributes were called 
``return_value`` and
+    ``side_effect`` respectively, but due to incompatibilities with 
``unittest.mock``
+    they had to be renamed (see `#175`_ for details).
+
+    .. _#175: https://github.com/pytest-dev/pytest-mock/issues/175
 
 Stub
 ----
 
-
-The stub is a mock object that accepts any arguments and is useful to test 
callbacks, for instance.
-May be passed a name to be used by the constructed stub object in its repr 
(useful for debugging).
+The stub is a mock object that accepts any arguments and is useful to test 
callbacks.
+It may receive an optional name that is shown in its ``repr``, useful for 
debugging.
 
 .. code-block:: python
 
@@ -125,7 +143,6 @@
 Improved reporting of mock call assertion errors
 ------------------------------------------------
 
-
 This plugin monkeypatches the mock library to improve pytest output for 
failures
 of mock call assertions like ``Mock.assert_called_with()`` by hiding internal 
traceback
 entries from the ``mock`` module.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/src/pytest_mock/_version.py 
new/pytest-mock-2.0.0/src/pytest_mock/_version.py
--- old/pytest-mock-1.12.1/src/pytest_mock/_version.py  2019-11-20 
23:07:42.000000000 +0100
+++ new/pytest-mock-2.0.0/src/pytest_mock/_version.py   2020-01-04 
19:44:55.000000000 +0100
@@ -1,4 +1,4 @@
 # coding: utf-8
 # file generated by setuptools_scm
 # don't change, don't track in version control
-version = '1.12.1'
+version = '2.0.0'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/src/pytest_mock/plugin.py 
new/pytest-mock-2.0.0/src/pytest_mock/plugin.py
--- old/pytest-mock-1.12.1/src/pytest_mock/plugin.py    2019-11-20 
23:07:32.000000000 +0100
+++ new/pytest-mock-2.0.0/src/pytest_mock/plugin.py     2020-01-04 
19:44:53.000000000 +0100
@@ -113,12 +113,21 @@
 
         @w
         def wrapper(*args, **kwargs):
-            r = method(*args, **kwargs)
-            result.return_value = r
+            spy_obj.spy_return = None
+            spy_obj.spy_exception = None
+            try:
+                r = method(*args, **kwargs)
+            except Exception as e:
+                spy_obj.spy_exception = e
+                raise
+            else:
+                spy_obj.spy_return = r
             return r
 
-        result = self.patch.object(obj, name, side_effect=wrapper, 
autospec=autospec)
-        return result
+        spy_obj = self.patch.object(obj, name, side_effect=wrapper, 
autospec=autospec)
+        spy_obj.spy_return = None
+        spy_obj.spy_exception = None
+        return spy_obj
 
     def stub(self, name=None):
         """
@@ -199,19 +208,6 @@
     result.stopall()
 
 
[email protected]
-def mock(mocker):
-    """
-    Same as "mocker", but kept only for backward compatibility.
-    """
-    import warnings
-
-    warnings.warn(
-        '"mock" fixture has been deprecated, use "mocker" instead', 
DeprecationWarning
-    )
-    return mocker
-
-
 _mock_module_patches = []
 _mock_module_originals = {}
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/src/pytest_mock.egg-info/PKG-INFO 
new/pytest-mock-2.0.0/src/pytest_mock.egg-info/PKG-INFO
--- old/pytest-mock-1.12.1/src/pytest_mock.egg-info/PKG-INFO    2019-11-20 
23:07:42.000000000 +0100
+++ new/pytest-mock-2.0.0/src/pytest_mock.egg-info/PKG-INFO     2020-01-04 
19:44:55.000000000 +0100
@@ -1,6 +1,6 @@
 Metadata-Version: 2.1
 Name: pytest-mock
-Version: 1.12.1
+Version: 2.0.0
 Summary: Thin-wrapper around the mock package for easier use with py.test
 Home-page: https://github.com/pytest-dev/pytest-mock/
 Author: Bruno Oliveira
@@ -10,10 +10,8 @@
         pytest-mock
         ===========
         
-        This plugin installs a ``mocker`` fixture which is a thin-wrapper 
around the patching API
-        provided by the `mock package <http://pypi.python.org/pypi/mock>`_,
-        but with the benefit of not having to worry about undoing patches at 
the end
-        of a test:
+        This plugin provides a ``mocker`` fixture which is a thin-wrapper 
around the patching API
+        provided by the `mock package <http://pypi.python.org/pypi/mock>`_:
         
         .. code-block:: python
         
@@ -31,6 +29,9 @@
                 os.remove.assert_called_once_with('file')
         
         
+        Besides undoing the mocking automatically after the end of the test, 
it also provides other
+        nice utilities such as ``spy`` and ``stub``, and uses pytest 
introspection when
+        comparing calls.
         
         |python| |version| |anaconda| |ci| |coverage| |black|
         
@@ -43,8 +44,8 @@
         .. |ci| image:: 
https://github.com/pytest-dev/pytest-mock/workflows/build/badge.svg
           :target: https://github.com/pytest-dev/pytest-mock/actions
         
-        .. |coverage| image:: 
http://img.shields.io/coveralls/pytest-dev/pytest-mock.svg
-          :target: https://coveralls.io/r/pytest-dev/pytest-mock
+        .. |coverage| image:: 
https://coveralls.io/repos/github/pytest-dev/pytest-mock/badge.svg?branch=master
+          :target: 
https://coveralls.io/github/pytest-dev/pytest-mock?branch=master
         
         .. |python| image:: 
https://img.shields.io/pypi/pyversions/pytest-mock.svg
           :target: https://pypi.python.org/pypi/pytest-mock/
@@ -78,7 +79,7 @@
         * `mocker.stopall 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.patch.stopall>`_
         * ``mocker.resetall()``: calls `reset_mock() 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.reset_mock>`_
 in all mocked objects up to this point.
         
-        These objects from the ``mock`` module are accessible directly from 
``mocker`` for convenience:
+        Also, as a convenience, these names from the ``mock`` module are 
accessible directly from ``mocker``:
         
         * `Mock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock>`_
         * `MagicMock 
<https://docs.python.org/3/library/unittest.mock.html#unittest.mock.MagicMock>`_
@@ -93,30 +94,47 @@
         Spy
         ---
         
-        The spy acts exactly like the original method in all cases, except it 
allows use of ``mock``
-        features with it, like retrieving call count. It also works for class 
and static methods.
+        The ``mocker.spy`` object acts exactly like the original method in all 
cases, except the spy
+        also tracks method calls, return values and exceptions raised.
         
         .. code-block:: python
         
             def test_spy(mocker):
                 class Foo(object):
-                    def bar(self):
-                        return 42
+                    def bar(self, v):
+                        return v * 2
         
                 foo = Foo()
-                mocker.spy(foo, 'bar')
-                assert foo.bar() == 42
-                assert foo.bar.call_count == 1
+                spy = mocker.spy(foo, 'bar')
+                assert foo.bar(21) == 42
         
-        Since version ``1.11``, it is also possible to query the 
``return_value`` attribute
-        to observe what the spied function/method returned.
+                spy.assert_called_once_with(21)
+                assert spy.spy_return == 42
+        
+        The object returned by ``mocker.spy`` is a ``MagicMock`` object, so 
all standard checking functions
+        are available (like ``assert_called_once_with`` in the example above).
+        
+        In addition, spy objects contain two extra attributes:
+        
+        * ``spy_return``: contains the returned value of the spied function.
+        * ``spy_exception``: contain the last exception value raised by the 
spied function/method when
+          it was last called, or ``None`` if no exception was raised.
+        
+        ``mocker.spy`` also works for class and static methods.
+        
+        .. note::
+        
+            In versions earlier than ``2.0``, the attributes were called 
``return_value`` and
+            ``side_effect`` respectively, but due to incompatibilities with 
``unittest.mock``
+            they had to be renamed (see `#175`_ for details).
+        
+            .. _#175: https://github.com/pytest-dev/pytest-mock/issues/175
         
         Stub
         ----
         
-        
-        The stub is a mock object that accepts any arguments and is useful to 
test callbacks, for instance.
-        May be passed a name to be used by the constructed stub object in its 
repr (useful for debugging).
+        The stub is a mock object that accepts any arguments and is useful to 
test callbacks.
+        It may receive an optional name that is shown in its ``repr``, useful 
for debugging.
         
         .. code-block:: python
         
@@ -133,7 +151,6 @@
         Improved reporting of mock call assertion errors
         ------------------------------------------------
         
-        
         This plugin monkeypatches the mock library to improve pytest output 
for failures
         of mock call assertions like ``Mock.assert_called_with()`` by hiding 
internal traceback
         entries from the ``mock`` module.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/pytest-mock-1.12.1/tests/test_pytest_mock.py 
new/pytest-mock-2.0.0/tests/test_pytest_mock.py
--- old/pytest-mock-1.12.1/tests/test_pytest_mock.py    2019-11-20 
23:07:32.000000000 +0100
+++ new/pytest-mock-2.0.0/tests/test_pytest_mock.py     2020-01-04 
19:44:53.000000000 +0100
@@ -132,28 +132,6 @@
     assert x == {"new": 10}
 
 
-def test_deprecated_mock(testdir):
-    """
-    Use backward-compatibility-only mock fixture to ensure complete coverage.
-    """
-    p1 = testdir.makepyfile(
-        """
-        import os
-
-        def test(mock, tmpdir):
-            mock.patch("os.listdir", return_value=["mocked"])
-            assert os.listdir(str(tmpdir)) == ["mocked"]
-            mock.stopall()
-            assert os.listdir(str(tmpdir)) == []
-        """
-    )
-    result = testdir.runpytest(str(p1))
-    result.stdout.fnmatch_lines(
-        ['*DeprecationWarning: "mock" fixture has been deprecated, use 
"mocker"*']
-    )
-    assert result.ret == 0
-
-
 @pytest.mark.parametrize(
     "name",
     [
@@ -238,9 +216,52 @@
     assert foo.bar(arg=10) == 20
     assert other.bar(arg=10) == 20
     foo.bar.assert_called_once_with(arg=10)
-    assert foo.bar.return_value == 20
+    assert foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
+
+
+def test_instance_method_spy_exception(mocker):
+    class Foo(object):
+        def bar(self, arg):
+            raise Exception("Error with {}".format(arg))
+
+    foo = Foo()
+    spy = mocker.spy(foo, "bar")
+
+    expected_calls = []
+    for i, v in enumerate([10, 20]):
+        with pytest.raises(Exception, match="Error with {}".format(v)) as 
exc_info:
+            foo.bar(arg=v)
+
+        expected_calls.append(mocker.call(arg=v))
+        assert foo.bar.call_args_list == expected_calls
+        assert str(spy.spy_exception) == "Error with {}".format(v)
+
+
+def test_spy_reset(mocker):
+    class Foo(object):
+        def bar(self, x):
+            if x == 0:
+                raise ValueError("invalid x")
+            return x * 3
+
+    spy = mocker.spy(Foo, "bar")
+    assert spy.spy_return is None
+    assert spy.spy_exception is None
+
+    Foo().bar(10)
+    assert spy.spy_return == 30
+    assert spy.spy_exception is None
+
+    with pytest.raises(ValueError):
+        Foo().bar(0)
+    assert spy.spy_return is None
+    assert str(spy.spy_exception) == "invalid x"
+
+    Foo().bar(15)
+    assert spy.spy_return == 45
+    assert spy.spy_exception is None
 
 
 @skip_pypy
@@ -274,7 +295,7 @@
     assert other.bar(arg=10) == 20
     calls = [mocker.call(foo, arg=10), mocker.call(other, arg=10)]
     assert spy.call_args_list == calls
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @skip_pypy
@@ -287,9 +308,9 @@
     spy = mocker.spy(Foo, "bar")
     assert Foo.bar(arg=10) == 20
     Foo.bar.assert_called_once_with(arg=10)
-    assert Foo.bar.return_value == 20
+    assert Foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @skip_pypy
@@ -306,9 +327,9 @@
     spy = mocker.spy(Foo, "bar")
     assert Foo.bar(arg=10) == 20
     Foo.bar.assert_called_once_with(arg=10)
-    assert Foo.bar.return_value == 20
+    assert Foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @skip_pypy
@@ -327,9 +348,9 @@
     spy = mocker.spy(Foo, "bar")
     assert Foo.bar(arg=10) == 20
     Foo.bar.assert_called_once_with(arg=10)
-    assert Foo.bar.return_value == 20
+    assert Foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @skip_pypy
@@ -342,9 +363,9 @@
     spy = mocker.spy(Foo, "bar")
     assert Foo.bar(arg=10) == 20
     Foo.bar.assert_called_once_with(arg=10)
-    assert Foo.bar.return_value == 20
+    assert Foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @skip_pypy
@@ -361,9 +382,9 @@
     spy = mocker.spy(Foo, "bar")
     assert Foo.bar(arg=10) == 20
     Foo.bar.assert_called_once_with(arg=10)
-    assert Foo.bar.return_value == 20
+    assert Foo.bar.spy_return == 20
     spy.assert_called_once_with(arg=10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 def test_callable_like_spy(testdir, mocker):
@@ -383,7 +404,7 @@
     spy = mocker.spy(uut, "call_like")
     uut.call_like(10)
     spy.assert_called_once_with(10)
-    assert spy.return_value == 20
+    assert spy.spy_return == 20
 
 
 @contextmanager


Reply via email to