Example #1
0
def test_range_check():

    # Floats are always returned
    assert range_check(10, 11) == (10.0, 11.0)
    assert range_check(6.4, 30) == (6.4, 30.0)

    # Invalid ranges give a ValueErro
    with raises(ValueError) as err:
        range_check(7, 2)
    assert str(err.value) == 'low >= high'
Example #2
0
def test_range_check_returns_range_as_is_if_first_is_less_than_second(x, d):
    # Pull data such that the first is less than the second.
    if isinstance(x, float):
        y = d.draw(floats(min_value=x + 1.0, max_value=1E9, allow_nan=False))
    else:
        y = d.draw(integers(min_value=x + 1))
    assert range_check(x, y) == (x, y)
Example #3
0
def test_range_check_returns_range_as_is_if_first_is_less_than_second(x, d):
    # Pull data such that the first is less than the second.
    if isinstance(x, float):
        y = d.draw(floats(min_value=x + 1.0, max_value=1e9, allow_nan=False))
    else:
        y = d.draw(integers(min_value=x + 1))
    assert range_check(x, y) == (x, y)
Example #4
0
def test_range_check_returns_range_as_is_but_with_floats_example():
    assert range_check(10, 11) == (10.0, 11.0)
    assert range_check(6.4, 30) == (6.4, 30.0)
Example #5
0
def test_range_check_raises_ValueError_if_second_is_less_than_first(x, data):
    # Pull data such that the first is greater than or equal to the second.
    y = data.draw(floats(max_value=x, allow_nan=False))
    with raises(ValueError) as err:
        range_check(x, y)
    assert str(err.value) == 'low >= high'
Example #6
0
def test_range_check_raises_ValueError_if_second_is_less_than_first_example():
    with raises(ValueError) as err:
        range_check(7, 2)
    assert str(err.value) == 'low >= high'
Example #7
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second(
        x, y):
    assume(float(x) < float(y))
    assert range_check(x, y) == (float(x), float(y))
Example #8
0
def test_range_check_raises_ValueError_if_second_is_less_than_first_example():
    with raises(ValueError) as err:
        range_check(7, 2)
    assert str(err.value) == 'low >= high'
Example #9
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second(x, y):
    assume(float(x) < float(y))
    assert range_check(x, y) == (float(x), float(y))
Example #10
0
def test_range_check_raises_value_error_if_second_is_less_than_first(x, d):
    # Pull data such that the first is greater than or equal to the second.
    y = d.draw(floats(max_value=x, allow_nan=False))
    with pytest.raises(ValueError, match="low >= high"):
        range_check(x, y)
Example #11
0
def test_range_check_raises_value_error_if_second_is_less_than_first_example():
    with pytest.raises(ValueError, match="low >= high"):
        range_check(7, 2)
Example #12
0
def test_range_check_returns_range_as_is_but_with_floats_example():
    assert range_check(10, 11) == (10.0, 11.0)
    assert range_check(6.4, 30) == (6.4, 30.0)
Example #13
0
def test_range_check_raises_ValueError_if_second_is_less_than_first(x, y):
    assume(x >= y)
    with raises(ValueError) as err:
        range_check(x, x)
    assert str(err.value) == 'low >= high'
Example #14
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second2(
        x, y):
    assume(x < y)
    assert range_check(x, y) == (x, y)
Example #15
0
def test_range_check_raises_ValueError_if_range_is_invalid():
    with raises(ValueError) as err:
        range_check(7, 2)
    assert str(err.value) == 'low >= high'
Example #16
0
def test_range_check_raises_value_error_if_second_is_less_than_first_example():
    with pytest.raises(ValueError, match="low >= high"):
        range_check(7, 2)
Example #17
0
def test_range_check_raises_value_error_if_second_is_less_than_first(x, d):
    # Pull data such that the first is greater than or equal to the second.
    y = d.draw(floats(max_value=x, allow_nan=False))
    with pytest.raises(ValueError, match="low >= high"):
        range_check(x, y)
Example #18
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second_example():
    assert range_check(10, 11) == (10.0, 11.0)
    assert range_check(6.4, 30) == (6.4, 30.0)
Example #19
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second_example(
):
    assert range_check(10, 11) == (10.0, 11.0)
    assert range_check(6.4, 30) == (6.4, 30.0)
Example #20
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second2(x, y):
    assume(x < y)
    assert range_check(x, y) == (x, y)
Example #21
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second(
        x, data):
    # Pull data such that the first is less than the second.
    y = data.draw(integers(min_value=x + 1))
    assert range_check(x, y) == (x, y)
Example #22
0
def test_range_check_raises_ValueError_if_second_is_less_than_first(x, y):
    assume(x >= y)
    with raises(ValueError) as err:
        range_check(x, x)
    assert str(err.value) == 'low >= high'
Example #23
0
def test_range_check_returns_range_as_is_but_with_floats_if_first_is_less_than_second2(
        x, data):
    # Pull data such that the first is less than the second.
    y = data.draw(floats(min_value=x + 1.0, max_value=1E9, allow_nan=False))
    assert range_check(x, y) == (x, y)