[Python-Dev] r87389 - in python/branches/py3k: Doc/library/unittest.rst Lib/unittest/case.py Misc/NEWS
Guido van Rossum
guido at python.org
Wed Dec 22 02:37:05 CET 2010
On Tue, Dec 21, 2010 at 5:12 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> I actually agree with Guido that anything we do is going to be
> suboptimal in some way. Encouraging the actual/expected ordering and
> updating the diff output so "expected=old" strikes me as least bad,
> but using the neutral first/second terminology and doing the diffs as
> "first=old" wouldn't be terrible (although I'm personally -0 on it
> because it encourages putting the expected value first in order to get
> the diffs the right way around when an error occurs).
There are several problems with the actual/expected terminology. First
of all, the arguments are primarily thought of as (and look)
positional, not as having names (and there's nothing you can do about
this in the docs -- people copy code without reading docs).
Furthermore, Java's jUnit puts expected first (and makes this part of
the culture/religion), so people coming from there will use that order
and be freaked out if you were to swap them. And last, the order of
diff arguments (old new) is also ingrained in the culture (which
actually matches the expected/actual order in my mind).
I think the least bad thing would be to drop any remnants of
expected/actual terminology, keep the diffs in the first-second order,
and let developers choose whether they put the expected value first or
second. Then of course there will still be the examples in the doc
(which some people *do* read and copy) -- I suppose we could alternate
here to emphasize that we don't have a preferred order.
--Guido van Rossum (python.org/~guido)
More information about the Python-Dev