How to do assert almost equal with py.test for floats without resorting to something like:
assert almost equal
assert x - 0.00001 <= y <= x + 0.00001 <
assert x - 0.00001 <= y <= x + 0.00001
You will have to specify what is "almost" for you:
assert abs(x-y) < 0.0001
to apply to tuples (or any sequence):
def almost_equal(x,y,threshold=0.0001): return abs(x-y) < threshold assert all(map(almost_equal, zip((1.32, 2.4), i_return_tuple_of_two_floats())