示例#1
0
def test_sort_list():
    """
    Check for sorted list by length.

    :return:
    """
    assert sort_list(["Bunny", "Tiger", "Bear", "Snake"]) == (['Bnny', 'Tgr', 'Snk', 'Br'])
    assert sort_list(["Red"]) == (["Rd"])
示例#2
0
def test_sort_list_empty():
    """
    Check for sorted list by length.

    :return:
    """
    assert sort_list([]) == []
    assert sort_list("") == []
    assert sort_list([""]) == ([""])
示例#3
0
def test_sort_list_empty_list():
    """
    List is empty.

    :return:
    """
    assert filter.sort_list([]) == []
示例#4
0
def test_sort_list_list_len_1():
    """Test when length of list is 1 in sort_list."""
    list_a = random.choices(
        "qwrtypsdfghjklzxcvbnmQWRTYPSDFGHJKLZXCVBNMaeiouAEIOU", k=10)
    string_a = "".join(list_a)
    list_a = [string_a]
    list_b = [None]
    list_b[0] = filter.remove_vowels(list_a[0])
    assert filter.sort_list(list_a) == list_b
示例#5
0
def test_sort_list_should_not_change_input_list():
    """
    Not change imput.

    :return:
    """
    list = []

    for i in range(random.randrange(1, 10)):
        string = ''.join(random.choice(allowed_chars) for _ in range(random.randrange(10, 40)))
        list.append(string)

    assert filter.sort_list(list) != list
示例#6
0
def test_sort_list_list_len_1():
    """
    List len 1.

    :return:
    """
    list = []
    test_list = []

    string = ''.join(random.choice(allowed_chars) for x in range(10, 40))
    list.append(string)

    for string in list:
        test_list.append(add_random_vowels(string, random.randrange(10, 40)))

    assert filter.sort_list(test_list) == list
示例#7
0
def test_sort_list_correct_order_with_same_length():
    """
    List elements with same length should keep order.

    :return:
    """
    list = []
    test_list = []

    for i in range(random.randrange(5, 10)):
        string = ''.join(random.choice(allowed_chars) for _ in range(10))
        list.append(string)

    for string in list:
        test_list.append(add_random_vowels(string, random.randrange(10, 40)))

    assert filter.sort_list(test_list) == list
示例#8
0
def test_sort_list_sort_before_remove_vowels():
    """Check code if it sorts before removing vowels."""
    assert sort_list(["cccc", "bbbbbbb", "aaaaaaaaaa"
                      ]) != ["aaaaaaaaaa", "bbbbbbb", "cccc"]
示例#9
0
def test_sort_list_should_not_change_input_list():
    """Check code wether the input list is changed or not."""
    a = ["Bear", "aaaaaaa", "nymphs"]
    b = ["Bear", "aaaaaaa", "nymphs"]
    sort_list(a)
    assert a == b
示例#10
0
def test_sort_list_list_len_1():
    """Check code when the return list has one element as a string."""
    assert sort_list(["Da"]) == ["D"]
示例#11
0
def test_sort_list_empty_list():
    """Check code when the input list is empty."""
    assert sort_list([]) == []
示例#12
0
def test_sort_list_correct_order_with_same_length():
    """Check code if it returns the list correctly when the output words are of the same size."""
    assert sort_list(["ttttt", "aaccccc",
                      "aaaabbbbb"]) == ["ttttt", "ccccc", "bbbbb"]
示例#13
0
def test_sort_list_empty_list():
    """Test when list empty in sort_list."""
    assert filter.sort_list([]) == []