[Python-Dev] PEP: Frequently-requested additional features for the unittest module (original) (raw)

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


Ben Finney wrote:

New condition tests -------------------

def assertlessthan(first, second, msg=None): op = operator.lt self.assertcomparetrue(op, first, second, msg) def assertgreaterthan(first, second, msg=None): op = operator.gt self.assertcomparetrue(op, first, second, msg) def assertlessthanorequal(first, second, msg=None): op = operator.le self.assertcomparetrue(op, first, second, msg) def assertgreaterthanorequal(first, second, msg=None): op = operator.ge self.assertcomparetrue(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 assertnotlessthan(first, second, msg=None) # Logical inverse of assertlessthan def assertnotgreaterthan(first, second, msg=None) # Logical inverse of assertgreaterthan def assertnotlessthanorequal(first, second, msg=None) # Logical inverse of assertlessthanorequal def assertnotgreaterthanorequal(first, second, msg=None) # Logical inverse of assertgreaterthanorequal

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