def test_validate_float1(): good = [0.5, 0, '0.123', 2, inf, nan] for value in good: val1 = validate_float(value) val2 = float(value) if not val1 is val2: assert_almost_equal(val1, val2)
def test_validate_float1(): good = [0.5, 0, '0.123', 2, inf, nan] for value in good: val1 = validate_float(value) val2 = float(value) if not val1 is val2: assert val1 == pytest.approx(val2)
def test_validate_float2(): bad = ['pants', float, []] for value in bad: with pytest.raises(ValueError): validate_float(value)