[Python-Dev] PEP: Consolidating names in the `unittest` module
Stephen J. Turnbull
stephen at xemacs.org
Wed Jul 16 00:20:40 CEST 2008
Ben Finney writes:
> Removal of ``assert*`` names
> ----------------------------
> Arguments in favour of retaining only the ``assert*`` names:
>
> * BDFL preference: The BDFL has stated [#vanrossum-1]_ a preference
> for the ``assert*`` names.
>
> * Precedent: The Python standard library currently uses the
> ``assert*`` names by a roughly 8:1 majority over the ``fail*``
> names. (Counting unit tests in the py3k tree at 2008-07-15
> [#pitrou-1]_.)
>
> An ad-hoc sampling of other projects that use `unittest` also
> demonstrates strong preference for use of the ``assert*`` names
> [#bennetts-1]_.
>
> * Positive admonition: The ``assert*`` names state the intent of how
> the code under test *should* behave, while the ``fail*`` names are
> phrased in terms of how the code *should not* behave.
FWIW, I think these are fairly stated. So fairly that I'm surprised
you haven't been persuaded!<wink> Nitpick: the second point is not
just "precedent", there's an economic reason there too. Tests in the
standard distribution which use the deprecated style will need to be
converted. Steven d'Aprano claims this is nontrivial (and thus error-
prone) in some cases. I haven't seen that claim denied, and it seems
plausible to me.
> PEP 8 names
> -----------
>
> Although `unittest` (and its predecessor `PyUnit`) are intended to be
> familiar to users of other xUnit interfaces, there is no attempt at
> direct API compatibility since the only code that Python's `unittest`
> interfaces with is other Python code. The module is in the standard
> library and its names should all conform with PEP 8 [#PEP-8]_.
You should mention Raymond's concern that PEP 8 names are quite a bit
longer.
More information about the Python-Dev
mailing list