[New-bugs-announce] [issue17826] Setting a side_effect on mock from create_autospec doesn't work

Michael Foord report at bugs.python.org
Wed Apr 24 12:00:08 CEST 2013


New submission from Michael Foord:

>>> from unittest.mock import create_autospec
>>> def f(): pass
... 
>>> m = create_autospec(f)
>>> m.side_effect = [1, 2]
>>> m()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in f
  File "/compile/py3k-cpython/Lib/unittest/mock.py", line 872, in __call__
    return _mock_self._mock_call(*args, **kwargs)
  File "/compile/py3k-cpython/Lib/unittest/mock.py", line 931, in _mock_call
    result = next(effect)
TypeError: 'list' object is not an iterator

----------
assignee: michael.foord
components: Library (Lib)
messages: 187692
nosy: michael.foord
priority: normal
severity: normal
stage: needs patch
status: open
title: Setting a side_effect on mock from create_autospec doesn't work
type: behavior
versions: Python 3.3, Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17826>
_______________________________________


More information about the New-bugs-announce mailing list