Skip to content

test_helpers

converter.tests.shieldhit.test_helpers

test_format_float

test_format_float(value, n, expected)

Test if format_float works on all the edge cases.

Source code in yaptide/converter/tests/shieldhit/test_helpers.py
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
@pytest.mark.parametrize("value,n,expected", [
    (1, 10, 1.0),
    (0, 10, 0.0),
    (-1, 10, -1.0),
    (1.0/3, 10, 0.33333333),
    (-1.0/3, 10, -0.3333333),
    (123+1.0/3, 10, 123.333333),
    (-(123+1.0/3), 10, -123.33333),
])
def test_format_float(value, n, expected):
    """Test if format_float works on all the edge cases."""
    assert format_float(value, n) == expected

test_format_float_large_example

test_format_float_large_example()

Test if format float will raise an exception when given bad arguments.

Source code in yaptide/converter/tests/shieldhit/test_helpers.py
19
20
21
22
def test_format_float_large_example():
    """Test if format float will raise an exception when given bad arguments."""
    with pytest.raises(ValueError):
        format_float(1000000, 2)