Пример #1
0
def test_value_error():
    # Check using single large number throws error
    with pytest.raises(ValueError) as ve:
        assert (list_to_decimal([10]))

    # Check using single large number out of many throws error
    with pytest.raises(ValueError) as ve:
        assert (list_to_decimal([1, 4, 5, 10]))

    with pytest.raises(ValueError) as ve:
        assert (list_to_decimal([]))
Пример #2
0
def test_type_error():
    # Check using float throws error
    with pytest.raises(TypeError) as ve:
        assert (list_to_decimal([1.1]))

    # Check using string throws error
    with pytest.raises(TypeError) as ve:
        assert (list_to_decimal(['one']))

    # Check if only one of many is a string
    with pytest.raises(TypeError) as ve:
        assert (list_to_decimal([1, 2, 3, '4']))

    # Check if only one of many value is float
    with pytest.raises(TypeError) as ve:
        assert (list_to_decimal([1, 2, 3, 4.5]))
Пример #3
0
def test_out_of_range():
    with pytest.raises(ValueError):
        list_to_decimal([10, 8])
    with pytest.raises(ValueError):
        list_to_decimal([1, 1222])
    with pytest.raises(ValueError):
        list_to_decimal([6, 2, -2])
    with pytest.raises(ValueError):
        list_to_decimal([-3, 1, 100])
Пример #4
0
def test_error_list_to_decimal():
    with pytest.raises(TypeError):
        list_to_decimal([True])
    with pytest.raises(TypeError):
        list_to_decimal([1, "1"])
    with pytest.raises(ValueError):
        list_to_decimal([0, 5, 11])
    with pytest.raises(ValueError):
        list_to_decimal([9, 10])
def test_check_outofrange():
    with pytest.raises(ValueError):
        list_to_decimal([-3, 5, 9])
    with pytest.raises(ValueError):
        list_to_decimal([11, 1, 2])
    with pytest.raises(ValueError):
        list_to_decimal([10, 3, 6])
def test_check_nonint():
    with pytest.raises(TypeError):
        list_to_decimal([1, 2, True])
    with pytest.raises(TypeError):
        list_to_decimal([1, 2, '5'])
    with pytest.raises(TypeError):
        list_to_decimal([1, 2.4, 8])
Пример #7
0
def test_correct():
    assert list_to_decimal([0, 4, 2, 8]) == 428
    assert list_to_decimal([1, 2]) == 12
    assert list_to_decimal([5, 2, 3, 5, 4, 2, 1]) == 5235421
    assert list_to_decimal([2, 1, 3]) == 213
    assert list_to_decimal([1, 0, 5, 0, 2]) == 10502
    assert list_to_decimal([1]) == 1
def test_normal():
    assert list_to_decimal([9]) == 9
    assert list_to_decimal([0]) == 0
    assert list_to_decimal([0, 1, 2]) == 12
    assert list_to_decimal([1, 0, 1]) == 101
Пример #9
0
def test_type_errors(nums):
    with pytest.raises(TypeError):
        list_to_decimal(nums)
Пример #10
0
def test_list_to_decimal(nums, expected):
    assert list_to_decimal(nums) == expected
Пример #11
0
def test_good_values(nums, expected):
    assert list_to_decimal(nums) == expected
def test_invalid_range():
    input = [10, 2, 3]

    with pytest.raises(ValueError):
        list_to_decimal(input)
def test_valid_values(input, expected):
    actual = list_to_decimal(input)
    assert actual == expected
Пример #14
0
def test_mutaion():
    """
    This did not help with testing mutation. 
    """
    if(list_to_decimal([10]) == 10):
        pytest.xfail("Extra test case to pass mutation test")
Пример #15
0
def test_range():
    with pytest.raises(ValueError):
        list_to_decimal([11,99])
Пример #16
0
def test_out_of_range_error() -> None:
    with pytest.raises(ValueError):
        value = list_to_decimal([0, 13, 2])
        if value == 132:
            raise ValueError
Пример #17
0
def test_list_to_decimal(arg, expected) -> None:
    assert list_to_decimal(arg) == expected
Пример #18
0
def test_list_to_decimal_raises_with_empty_input():
    with pytest.raises(ValueError):
        list_to_decimal([])
def test_invalid_input_types(input):
    with pytest.raises(TypeError):
        list_to_decimal(input)
Пример #20
0
def test_list_to_decimal_raises_with_negative_numbers(input_numbers):
    with pytest.raises(ValueError):
        list_to_decimal(input_numbers)
Пример #21
0
def test_not_raise_exceptions(nums):
    try:
        list_to_decimal(nums)
    except (ValueError, TypeError) as e:
        pytest.fail("Unexpetced " + str(e))
Пример #22
0
def test_list_to_decimal_raises_if_numbers_too_large(input_numbers):
    with pytest.raises(ValueError):
        list_to_decimal(input_numbers)
Пример #23
0
def test_raise_error(nums, expected_error):
    with pytest.raises(expected_error):
        assert list_to_decimal(nums)
Пример #24
0
def test_list_to_decimal_raises_if_numbers_are_not_int(input_numbers):
    with pytest.raises(TypeError):
        list_to_decimal(input_numbers)
Пример #25
0
def test_value_errors(nums):
    with pytest.raises(ValueError):
        list_to_decimal(nums)
Пример #26
0
def test_list_to_decimal(input_numbers, expected):
    assert list_to_decimal(input_numbers) == expected
def test_negative():
    with pytest.raises(ValueError):
        list_to_decimal([-1])
        list_to_decimal([10])
        list_to_decimal([])
Пример #28
0
def test_TypeError(arg) -> None:
    with pytest.raises(TypeError):
        result = list_to_decimal(arg)
def test_not_int():
    with pytest.raises(TypeError):
        list_to_decimal([True])
        list_to_decimal([False])
        list_to_decimal()
Пример #30
0
def test_ValueError() -> None:
    with pytest.raises(ValueError):
        result = list_to_decimal(arg)