Message238064
The following fails on python 3.4.2, 3.4.3 and 3.5.0a2 (downloaded from python.org and compiled on Ubuntu 14.04).
The same happens when using mock.patch with autospec=True.
>>> from unittest.mock import create_autospec
>>> def function():
... pass
...
>>> mock = create_autospec(function)
>>> mock.side_effect = ValueError('MyError')
>>> mock()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 3, in function
File "/usr/local/lib/python3.5/unittest/mock.py", line 910, in __call__
return _mock_self._mock_call(*args, **kwargs)
File "/usr/local/lib/python3.5/unittest/mock.py", line 963, in _mock_call
effect = self.side_effect
File "/usr/local/lib/python3.5/unittest/mock.py", line 510, in __get_side_effect
sf = _MockIter(sf)
File "/usr/local/lib/python3.5/unittest/mock.py", line 351, in __init__
self.obj = iter(obj)
TypeError: 'ValueError' object is not iterable
But, on Python 3.3.5, 3.4.0, or when the mock is created via Mock(), for instance, the exception is raised as expected:
[...]
>>> mock()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 3, in function
File "/usr/lib/python3.4/unittest/mock.py", line 885, in __call__
return _mock_self._mock_call(*args, **kwargs)
File "/usr/lib/python3.4/unittest/mock.py", line 941, in _mock_call
raise effect
ValueError: MyError |
|
Date |
User |
Action |
Args |
2015-03-14 00:45:40 | Ignacio Rossi | set | recipients:
+ Ignacio Rossi |
2015-03-14 00:45:40 | Ignacio Rossi | set | messageid: <1426293940.15.0.253058774664.issue23661@psf.upfronthosting.co.za> |
2015-03-14 00:45:40 | Ignacio Rossi | link | issue23661 messages |
2015-03-14 00:45:39 | Ignacio Rossi | create | |
|