[Python-Dev] PEP: Frequently-requested additional features for the `unittest` module
fuzzyman at voidspace.org.uk
Wed Jul 16 14:30:58 CEST 2008
Brett Cannon wrote:
> On Tue, Jul 15, 2008 at 7:05 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
>> Scott Dial <scott+python-dev at scottdial.com> writes:
>>> Why [introduce redundant test names]?
>>> assert_not_less_than = assert_greater_than_or_equal
>>> assert_not_greater_than = assert_less_than_or_equal
>>> assert_not_less_than_or_equal = assert_greater_than
>>> assert_not_greater_than_or_equal = assert_less_than
>> To answer the question: The above tests are logically equivalent, but
>> the failure message would be different, reporting failure in terms of
>> what the caller wanted to test.
>> I se your point though. I'd like to see what others think on this
>>> Besides, ``assert_not_greater_than_or_equal`` is god-awful-long,
>>> along with the complaints about PEP-8-ifying. I wonder if it would
>>> be better to abbreviate these names with the *same name* that was
>>> used for the attribute in the operator module. Let's not reinvent
>>> the wheel here..
>> Interesting. So you advocate collapsing the above eight tests into the
>> following four:
> Is any of this really necessary? Isn't this the equivalent of
> ``assert_(a < b)``? It seems like the only thing you get out of this
> is a nicer error message, but ``assert_(a < b, 'not %r <= %s' % (a,
> b))`` is not that complex. And do these cases really come up that
> often? I would want to see some numbers showing that these are really
> necessary (in both usage and people even specifying an error message
> in the first place).
I'm inclined to agree. It was part of a set of additions suggested by
Guido. From here I think (as part of the unittest extensions that google
I've used tests like that when implementing numeric objects, which has
been several times - but only a tiny proportion of the tests I've written.
I wouldn't be sorry not to include them.
> Python-Dev mailing list
> Python-Dev at python.org
> Unsubscribe: http://mail.python.org/mailman/options/python-dev/fuzzyman%40voidspace.org.uk
More information about the Python-Dev