[Python-Dev] unittest missing assertNotRaises

Laurens Van Houtven _ at lvh.cc
Wed Sep 28 16:59:12 CEST 2011


Oops, I accidentally hit Reply instead of Reply to All...

On Wed, Sep 28, 2011 at 1:05 PM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:

>  On 27/09/2011 19:59, Laurens Van Houtven wrote:
>
> Sure, you just *do* it. The only advantage I see in assertNotRaises is that
> when that exception is raised, you should (and would) get a failure, not an
> error.
>
> There are some who don't see the distinction between a failure and an error
> as a useful distinction... I'm becoming more sympathetic to that view.
>

I agree. Maybe if there were less failures posing as errors and errors
posing as failures, I'd consider taking the distinction seriously.

The only use case I've personally encountered is with fuzzy tests. The
example that comes to mind is one where we had a fairly complex iterative
algorithm for learning things from huge amounts of test data and there were
certain criteria (goodness of result, time taken) that had to be satisfied.
In that case, "it blew up because someone messed up dependencies" and "it
took 3% longer than is allowable"  are pretty obviously different...
Considering how exotic that use case is, like I said, I'm not really
convinced how generally useful it is :) especially since this isn't even a
unit test...



> All the best,
>
> Michael
>

cheers
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20110928/7893d845/attachment.html>


More information about the Python-Dev mailing list