kgashok / pymox

Automatically exported from code.google.com/p/pymox
Apache License 2.0
0 stars 0 forks source link

Mox sometimes swallows unexpected method calls #16

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Tested againt latest trunk (rev. 38)

I've encountered one bad issue in mock: it can sometimes happen that an
error is silently "swallowed" by the mocking framework. (see the attached
file).

Basically, what happens is that MockMethod just raises an exception
immediately if the method is called unexpectedly. But if the exception is
trapped in the caller code, e.g. something like

try:
    mockobject.callUnknownMethod()
except:
    log.error.something(....)

the exception is swallowed and the test passes without error.

Of course, the try...except in the caller code might be perfectly legit
(because there might be the absolute need the func not to throw at
anytime), but it is aimed at catching exceptions which are raised by the
function call itself, not by the fact that the function should not be called.

I do not provide a patch since I think this would need a bit of "rework",
e.g. a MockMethod raising such error should trigger a change in the
"global" Mox object state which should then be re-raised when calling
VerifyAll().

Original issue reported on code.google.com by alan.fra...@gmail.com on 21 Dec 2009 at 3:38

Attachments:

GoogleCodeExporter commented 8 years ago
I'll see if I can get around to adding this over my holiday break.

Original comment by steve.mi...@gmail.com on 21 Dec 2009 at 4:54

GoogleCodeExporter commented 8 years ago
Fixed in v72.  Thanks!

Original comment by stev...@google.com on 1 May 2012 at 9:28