def test_string_support(self): """Numbers given as strings must be converted first""" # The constant as a string: op = Number("10") ok_(op.equals(10, None)) ok_(op.equals(10.00, None)) # The other operand as string: op = Number(10) ok_(op.equals("10", None)) ok_(op.equals("10.00", None)) ok_(op.less_than("11", None)) ok_(op.greater_than("9", None)) assert_false(op.less_than("9", None)) assert_false(op.greater_than("11", None))
def test_greater_than(self): # With an integer constant: op = Number(10) ok_(op.greater_than(9, None)) ok_(op.greater_than(9.99999, None)) assert_false(op.greater_than(10.00001, None)) # With a float constant: op = Number(10.00) ok_(op.greater_than(9, None)) ok_(op.greater_than(9.99999, None)) assert_false(op.greater_than(10.00001, None)) # With everything but a number: assert_raises(InvalidOperationError, op.greater_than, "ten", None)