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

Antoine Pitrou solipsis at pitrou.net
Sun Jul 13 14:25:35 CEST 2008


Andrew Bennetts <andrew-pythondev puzzling.org> writes:

On the other hand, “assert*” names are positive statements of what the behaviour of the system-under-test is. And conversely, “fail*” names are a bit like implementation details of how the test is written. So I personally have a mild preference for the assert* names.

The problem with "fail*" is that you get names like "failIfNotEqual" (or perhaps even "failUnlessNotEqual") which are double negatives and therefore much more annoying to read and decipher. I always had the same problem when reading Perl's "unless" statements. They are, IMO, useless complication.

"assert*" names are, well, assertive :-)

(not to mention "assert" is a widely established name in various languages - including Python - for checking that things went as expected)



More information about the Python-Dev mailing list