What steps will reproduce the problem? 1. Run the attached file: python test.py
What is the expected output? What do you see instead? Expected: Both tests pass. Result: One test fails with this stack trace:
===================================================
ERROR: test_show_side_effect_bug (main.BugTestCase)
Traceback (most recent call last): File "test.py", line 18, in test_show_side_effect_bug self.assertIs(A().f1(), 1) File "<string>", line 3, in f1 File "python2.7/site-packages/mock.py", line 955, in call return _mock_self._mock_call(*args, **kwargs) File "python2.7/site-packages/mock.py", line 1013, in _mock_call result = next(effect) TypeError: list object is not an iterator
What version of the product are you using? On what operating system? Mock==1.0.1 OSX 10.9.5
Please provide any additional information below. Doesn't seem to be a high priority, since the workaround is easy. I'm guessing fix will come either around line 1007 in mock.py, or somewhere earlier in the autospec-specific code.
- test.py 582
Comment #1
Posted on Dec 22, 2014 by Massive LionComment deleted
Comment #2
Posted on Dec 22, 2014 by Massive LionWorkaround as shown in test.py: my_mock.side_effect = ['option1', 'option2'].iter()
Better: my_mock.side_effect = iter(['option1', 'option2'])
Comment #3
Posted on Jan 30, 2015 by Grumpy HorseI hit this issue. today. I can see that this is fixed in Python 3 stdlib one. Is there anyway to back port it?
Status: New
Labels:
Type-Defect
Priority-Medium