hRobert12 / mock

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

"wraps" should work with "side_effect" #251

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The "wraps" keyword allows us to specify that a mock wraps another object, 
delegating method calls to that object. Per the documentation, the delegation 
can be overridden by specifying a "return_value" for that method on the mock as 
usual.

On the other hand, "side_effect", among other things, allows us to specify a 
callable to generate the return value instead of specifying it explicitly.

Each of these features are very useful, and indispensable for some cases. There 
are, of course, some cases where using _both_ would be very handy. 
Unfortunately, this is not currently supported. The "side_effect" attribute is 
currently ignored for method calls on Mock objects using "wraps". It should be 
supported just as "return_value" is.

wraps and side_effect: two great tastes that taste great together!

Original issue reported on code.google.com by m...@nerone.org on 13 May 2015 at 10:40