diff options
author | Michael Foord <michael@voidspace.org.uk> | 2012-04-21 14:52:11 (GMT) |
---|---|---|
committer | Michael Foord <michael@voidspace.org.uk> | 2012-04-21 14:52:11 (GMT) |
commit | 2cd48738ba0a593a6edf6f4f41b420ead3719e71 (patch) | |
tree | 767327ab8cb7c811e009645623cd29ecc588cc20 /Doc/library/unittest.mock.rst | |
parent | 24117a748b02e0d2d028956c7b118f4ecd55361c (diff) | |
download | cpython-2cd48738ba0a593a6edf6f4f41b420ead3719e71.zip cpython-2cd48738ba0a593a6edf6f4f41b420ead3719e71.tar.gz cpython-2cd48738ba0a593a6edf6f4f41b420ead3719e71.tar.bz2 |
Closes issue 14636. mock objects raise exceptions from an iterable side_effect
Diffstat (limited to 'Doc/library/unittest.mock.rst')
-rw-r--r-- | Doc/library/unittest.mock.rst | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/library/unittest.mock.rst b/Doc/library/unittest.mock.rst index ed6775a..12b0275 100644 --- a/Doc/library/unittest.mock.rst +++ b/Doc/library/unittest.mock.rst @@ -823,6 +823,20 @@ a `StopIteration` is raised): ... StopIteration +If any members of the iterable are exceptions they will be raised instead of +returned:: + + >>> iterable = (33, ValueError, 66) + >>> m = MagicMock(side_effect=iterable) + >>> m() + 33 + >>> m() + Traceback (most recent call last): + ... + ValueError + >>> m() + 66 + .. _deleting-attributes: |