[New-bugs-announce] [issue14636] Mock could check for exceptions in side effect list

R. David Murray report at bugs.python.org
Fri Apr 20 22:38:09 CEST 2012

New submission from R. David Murray <rdmurray at bitdance.com>:

I just spent an hour figuring out why my test was failing because I tried to do this:

   mymock.side_effect = (AuthenticationError, None)

expecting the first call to raise an auth error and the second time it was called to get a normal return.

Since there are almost zero circumstances in which one would really want to return an exception, is there any reason not to have mock check for exceptions and raise them in this circumstance?  (If one did need to return an exception one could write a function...which is what one has to do now for the above case, but the above case seems more commonly needed than returning an exception would be.)

components: Library (Lib)
keywords: easy
messages: 158883
nosy: michael.foord, r.david.murray
priority: normal
severity: normal
stage: needs patch
status: open
title: Mock could check for exceptions in side effect list
type: enhancement
versions: Python 3.3

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list