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

Ben Finney bignose+hates-spam at benfinney.id.au
Sun Jul 13 14:36:27 CEST 2008


Antoine Pitrou <solipsis at pitrou.net> writes:
> The problem with "fail*" is that you get names like "failIfNotEqual"

That would better be written (preferring PEP 8 names)
"fail_unless_equal".
> (or perhaps even "failUnlessNotEqual")

idem, "fail_if_equal".
> which are double negatives

Exactly. With "if" and "unless" at our disposal, we can avoid such
double negatives.
> (not to mention "assert" is a widely established name in various
> languages - including Python - for checking that things went as
> expected)

That's another reason to avoid "assert" in the name: these methods
*don't* necessarily use the 'assert' statement. Avoiding the
implication that they do use that is a good thing.
-- 
 \ “Never do anything against conscience even if the state demands |
 `\ it.” —Albert Einstein |
_o__) |
Ben Finney


More information about the Python-Dev mailing list

AltStyle によって変換されたページ (->オリジナル) /