[Python-Dev] PEP: Consolidating names and classes in the `unittest`module (updated 2008-07-15)

Ben Finney ben+python at benfinney.id.au
Tue Jul 15 15:03:01 CEST 2008


Nick Coghlan <ncoghlan at gmail.com> writes:

> fail_if_almost_equal is an undesirably long method name.

I disagree. It says what the method does, as precisely as necessary to
distinguish it from other methods of the class. It is as long as it
needs to be to say that while still being readable and PEP 8
compliant.

> One option for rationalising the API would be to merely keep the
> shortest version of each phrase (i.e. use assert* instead of
> fail_unless* for the positive tests and fail_if* instead of
> assert_not* for the negative tests, and always drop the trailing 's'
> from 'equals').

I think clarity, consistency, and discoverability are more important
criteria than saving a few characters in a method name.

> Adding in possible positive and negative forms of the proposed new
> methods

A major point of this PEP is to *remove* redundant names in the API.

-- 
 \          “It's dangerous to be right when the government is wrong.” |
  `\                                   —Francois Marie Arouet Voltaire |
_o__)                                                                  |
Ben Finney



More information about the Python-Dev mailing list