[Python-Dev] PEP: Frequently-requested additional features for the `unittest` module

Scott Dial scott+python-dev at scottdial.com
Wed Jul 16 03:41:54 CEST 2008


Ben Finney wrote:
> New condition tests
> -------------------
> 
>         def assert_less_than(first, second, msg=None):
>             op = operator.lt
>             self.assert_compare_true(op, first, second, msg)
> 
>         def assert_greater_than(first, second, msg=None):
>             op = operator.gt
>             self.assert_compare_true(op, first, second, msg)
> 
>         def assert_less_than_or_equal(first, second, msg=None):
>             op = operator.le
>             self.assert_compare_true(op, first, second, msg)
> 
>         def assert_greater_than_or_equal(first, second, msg=None):
>             op = operator.ge
>             self.assert_compare_true(op, first, second, msg)
> 
> The following test methods are also added. Their implementation in
> each case is simply the logical inverse of a corresponding method
> above.
> 
>         def assert_not_less_than(first, second, msg=None)
>             # Logical inverse of assert_less_than
> 
>         def assert_not_greater_than(first, second, msg=None)
>             # Logical inverse of assert_greater_than
> 
>         def assert_not_less_than_or_equal(first, second, msg=None)
>             # Logical inverse of assert_less_than_or_equal
> 
>         def assert_not_greater_than_or_equal(first, second, msg=None)
>             # Logical inverse of assert_greater_than_or_equal

Why?! Your other PEP is about removing redundant names, and here you 
have introduced 4 of them:

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

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..

-- 
Scott Dial
scott at scottdial.com
scodial at cs.indiana.edu


More information about the Python-Dev mailing list