sorenisanerd / mock

Automatically exported from code.google.com/p/mock
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

side_effects iterator does not honor sentinel.DEFAULT #190

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
A mock with a return_value and a side_effects iterable will not return the 
given return_value when the side_effect is DEFAULT.
From the attached patch:

mock = Mock(return_value=2)
mock.side_effect = iter([1, DEFAULT])
self.assertEqual([mock(), mock()], [1, 2])

What is the expected output? What do you see instead?
When side_effect is an iterable and one item is sentinel.DEFAULT the 
corresponding call to the mock should return the return_value given in the mock 
constructor. Instead it returns sentinel.DEFAULT.

What version of the product are you using? On what operating system?
Tested with changeset 950:63c726990a85.

Please provide any additional information below.
The attached patch includes a test case and a fix.

Original issue reported on code.google.com by oseem...@gmail.com on 22 Nov 2012 at 9:42

Attachments:

GoogleCodeExporter commented 9 years ago
Good point, thanks for the report and patch.

Original comment by fuzzyman on 23 Nov 2012 at 10:23