[Python-Dev] unittest's redundant assertions: asserts vs. failIf/Unlesses

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Jul 14 03:14:28 CEST 2008


Steve Holden wrote:

> "Fail" isn't a negative.

That depends on what you're trying to find out by reading
the code. If you're trying to find out under what conditions
the test succeeds, then it succeeds if it doesn't fail, so
you have a negative.

Whichever convention is chosen, there will be situations in
which you want to mentally negate it. If you start with a
positive, the mental negation produces a single negative.
If you start with a negative, the mental negation produces
a double negative. Therefore it is less confusing overall
to start with as few negatives as possible.

-- 
Greg


More information about the Python-Dev mailing list