derwiki-adroll / mock

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

_patch does not allow subclasses to catch exceptions in __exit__ #141

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. subclass _patch
2. try to handle an exception in the context manager

What is the expected output? What do you see instead?

You do not get notified of the exception because mock calls __exit__() in 
several places without passing along the exception args

What version of the product are you using? On what operating system?

Please provide any additional information below.

Original issue reported on code.google.com by kumar.mcmillan on 15 Mar 2012 at 4:27

GoogleCodeExporter commented 9 years ago
Can you suggest a patch?

Original comment by fuzzyman on 15 Mar 2012 at 4:37

GoogleCodeExporter commented 9 years ago
Hi Michael, I found this bug when working on integrating mock into fudge. Here 
is a patch for it: 
http://code.google.com/r/kumarmcmillan-mock/source/detail?r=2f0b1c94f6ea457f33ff
64aec76579f100f08852

Original comment by kumar.mcmillan on 15 Mar 2012 at 4:38

GoogleCodeExporter commented 9 years ago
Let me know how it looks

Original comment by kumar.mcmillan on 15 Mar 2012 at 5:01

GoogleCodeExporter commented 9 years ago
so far, this looks like the only thing blocking fudge from using mock

Original comment by kumar.mcmillan on 18 Mar 2012 at 4:31

GoogleCodeExporter commented 9 years ago
Cool. If there's any way that fudge could use MagicMock or Mock as well then 
let me know.

I'm pulling your changes in. There'll be your test to ensure I don't break this 
in the future - however I'm not adding _patch and _get_target to the public api 
by adding them to __all__.

Original comment by fuzzyman on 20 Mar 2012 at 12:38

GoogleCodeExporter commented 9 years ago
Oh, my mistake - you didn't add them to __all__ you just import them for the 
test. Ignore that last comment. Note that I've had to modify your patch 
slightly as the mocksignature argument to _patch is gone in 1.0.

Original comment by fuzzyman on 20 Mar 2012 at 12:40

GoogleCodeExporter commented 9 years ago

Original comment by fuzzyman on 20 Mar 2012 at 12:40

GoogleCodeExporter commented 9 years ago
This issue was closed by revision 2f0b1c94f6ea.

Original comment by fuzzyman on 20 Mar 2012 at 12:50

GoogleCodeExporter commented 9 years ago
Now committed on trunk. This will be released as 1.0 alpha 1 shortly.

Original comment by fuzzyman on 20 Mar 2012 at 12:51

GoogleCodeExporter commented 9 years ago
thanks!

Original comment by kumar.mcmillan on 20 Mar 2012 at 6:03