Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ In addition, spy objects contain four extra attributes:

* ``spy_return``: contains the last returned value of the spied function.
* ``spy_return_iter``: contains a duplicate of the last returned value of the spied function if the value was an iterator and spy was created using ``.spy(..., duplicate_iterators=True)``. Uses `tee <https://docs.python.org/3/library/itertools.html#itertools.tee>`__) to duplicate the iterator.
* ``spy_return_list``: contains a list of all returned values of the spied function (new in ``3.13``).
* ``spy_return_list``: contains a list of all returned values of the spied function (new in ``3.13``). If the mock was called multiple times, the list is sorted descendingly: the last value comes first.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not right, the last call comes last:

class C:

	def foo(self, x): return x

def test(mocker):

	spy = mocker.spy(C, "foo")
	c = C()
	c.foo(10)
	c.foo(20)
	print(spy.spy_return_list)
	assert 0
----------------------------- Captured stdout call -----------------------------
[10, 20]

* ``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.

Expand Down