Exemplo n.º 1
0
def test_combine_strings_num_combinations(strings):
    combinations = mixemup.combine_strings(strings)
    num_combinations = sum(1 for c in combinations)

    expected_length = 0
    for i in range(num_combinations + 1):
        expected_length += sum(1 for i in itertools.combinations(strings, i))

    assert num_combinations == expected_length
Exemplo n.º 2
0
def test_combine_strings_max_parts_negative():
    strings = ["a", "b", "c"]
    with pytest.raises(ValueError):
        next(mixemup.combine_strings(strings, max_parts=-1))
Exemplo n.º 3
0
def test_combine_strings_max_parts_zero():
    strings = ["a", "b", "c"]
    combinations = list(mixemup.combine_strings(strings, max_parts=0))
    assert combinations[-1] == ""
Exemplo n.º 4
0
def test_combine_strings_max_parts_in_range(max_parts):
    strings = ["a", "b", "c"]
    combinations = list(mixemup.combine_strings(strings, max_parts=max_parts))
    assert len(combinations[-1].split(" ")) == max_parts
Exemplo n.º 5
0
def test_combine_strings_delimiter(delimiter):
    strings = ["a", "b", "c"]
    combinations_custom = mixemup.combine_strings(strings, delimiter)
    combinations_default = mixemup.combine_strings(strings)
    for custom, default in zip(combinations_custom, combinations_default):
        assert custom.split(delimiter) == default.split(" ")