Exemple #1
0
def test_sep_inserter_inserts_separator_between_two_numbers(x):
    # Rather than just replicating the the results in a different
    # algorithm, validate that the "shape" of the output is as expected.
    result = list(utils.sep_inserter(iter(x), ""))
    for i, pos in enumerate(result[1:-1], 1):
        if pos == "":
            assert isinstance(result[i - 1], py23_int)
            assert isinstance(result[i + 1], py23_int)
Exemple #2
0
def test_sep_inserter_inserts_separator_between_two_numbers(x):
    # Rather than just replicating the the results in a different
    # algorithm, validate that the "shape" of the output is as expected.
    result = list(utils.sep_inserter(iter(x), ""))
    for i, pos in enumerate(result[1:-1], 1):
        if pos == "":
            assert isinstance(result[i - 1], py23_int)
            assert isinstance(result[i + 1], py23_int)
Exemple #3
0
def test_sep_inserter_inserts_separator_string_between_two_numbers_example():
    assert list(utils.sep_inserter(iter([5, 9]), "")) == ["", 5, "", 9]
Exemple #4
0
def test_sep_inserter_does_nothing_if_only_one_number_example():
    assert list(utils.sep_inserter(iter(["a", 5]), "")) == ["a", 5]
Exemple #5
0
def test_sep_inserter_does_nothing_if_no_numbers_example():
    assert list(utils.sep_inserter(iter(["a", "b", "c"]),
                                   "")) == ["a", "b", "c"]
    assert list(utils.sep_inserter(iter(["a"]), "")) == ["a"]
Exemple #6
0
def test_sep_inserter_inserts_separator_string_between_two_numbers_example():
    assert list(utils.sep_inserter(iter([5, 9]), "")) == ["", 5, "", 9]
Exemple #7
0
def test_sep_inserter_does_nothing_if_only_one_number_example():
    assert list(utils.sep_inserter(iter(["a", 5]), "")) == ["a", 5]
Exemple #8
0
def test_sep_inserter_does_nothing_if_no_numbers_example():
    assert list(utils.sep_inserter(iter(["a", "b", "c"]), "")) == ["a", "b", "c"]
    assert list(utils.sep_inserter(iter(["a"]), "")) == ["a"]