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

Ben Finney bignose+hates-spam at benfinney.id.au
Sun Jul 13 11:29:22 CEST 2008


"Guido van Rossum" <guido at python.org> writes:

> Same here; let's tread carefully here and not change this with 3.0.
> Starting to deprecate in 3.1 and killing in 3.3 would be soon enough.

I'm very glad this is on the table. Even though I'd really like to see
the names become PEP-8-conformant in the 2.x series, the arguments
against such haste are compelling.

So I'm convinced to be +1 on post-3.0 for changing the unittest API.

> I like using only the assertKeyword variants, removing assert_, fail*,
> and assertEquals.

I'm the opposite. I prefer the 'fail*' variants over the 'assert*'
variants, because "fail" tells me exactly what the function will *do*,
while "assert" leaves it implicit what will actually happen if the
assertion is false.

For this reason, I'd prefer the "fail*" names to be recommended, and
the "assert*" names to be, if not deprecated, then at least
second-class citizens.

-- 
 \         “I think there is a world market for maybe five computers.” |
  `\                             —Thomas Watson, chairman of IBM, 1943 |
_o__)                                                                  |
Ben Finney



More information about the Python-Dev mailing list