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

Antoine Pitrou solipsis at pitrou.net
Sun Jul 13 15:07:05 CEST 2008


Ben Finney <bignose+hates-spam <at> benfinney.id.au> writes:
> 
> That would better be written (preferring PEP 8 names)
> "fail_unless_equal".

Which is still a double negative ("fail" and "unless" are both negative words).

> That's another reason to avoid "assert" in the name: these methods
> *don't* necessarily use the 'assert' statement.

But all those constructs (assert, assertEqual, etc.) raise the same exception
type named AssertionError which, if you care for naming consistency, is more
important than whether or not they are implemented in terms of each other. :-)





More information about the Python-Dev mailing list