예제 #1
0
def test_0_additional_arg():
    """Testing that with no additional args returns same iterable"""
    assert custom_range(string.ascii_lowercase) == [
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z",
    ]
예제 #2
0
def test_arg_is_not_in_sequence():
    """Testing that if at least 1 arg is not in sequence returns same iterable"""
    assert custom_range(string.ascii_lowercase) == [
        "a",
        "b",
        "c",
        "d",
        "e",
        "f",
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
        "p",
        "q",
        "r",
        "s",
        "t",
        "u",
        "v",
        "w",
        "x",
        "y",
        "z",
    ]
예제 #3
0
def test_3_additional_args_negative_step():
    """Testing that if 3 additional args and 3rd is negative
    returns everything from 1st arg inclusively and 2nd arg exclusively with 3rd arg as negative step"""
    assert custom_range(string.ascii_lowercase, "p", "g", -2) == [
        "p",
        "n",
        "l",
        "j",
        "h",
    ]
예제 #4
0
def test_2_additional_args():
    """Testing that if 2 additional args returns everything from 1st arg (inclusively) up to 2nd arg exclusively"""
    assert custom_range(string.ascii_lowercase, "g", "p") == [
        "g",
        "h",
        "i",
        "j",
        "k",
        "l",
        "m",
        "n",
        "o",
    ]
예제 #5
0
def test_custom_range_with_stop():
    """Testing that with iterable and one else arg that arg works as stop."""
    expected = ["a", "b", "c", "d", "e", "f"]
    assert custom_range(string.ascii_lowercase, "g") == expected
예제 #6
0
def test_custom_range_with_step():
    """Testing that third arg after iterable works like a step for range."""
    expected = ["p", "n", "l", "j", "h"]
    assert custom_range(string.ascii_lowercase, "p", "g", -2) == expected
예제 #7
0
def test_custom_range_with_start_and_stop():
    """Testing that 2 args with iterable gives start and stop element for range."""
    expected = ["g", "h", "i", "j", "k", "l", "m", "n", "o"]
    assert custom_range(string.ascii_lowercase, "g", "p") == expected
예제 #8
0
def test_1_additional_arg():
    """Testing that if 1 additional argument returns everything up to this argument exclusively"""
    assert custom_range(string.ascii_lowercase,
                        "g") == ["a", "b", "c", "d", "e", "f"]
예제 #9
0
def test_3_additional_args_positive_step():
    """Testing that if 3 additional args and 3rd is positive
    returns everything from 1st arg inclusively and 2nd arg exclusively with 3rd arg as positive step"""
    assert custom_range(string.ascii_lowercase, "a", "e", 2) == ["a", "c"]
예제 #10
0
def test_custom_range(args: Any, expected_result: List[Any]):

    actual_result = custom_range(*args)

    assert actual_result == expected_result