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)
def test_sep_inserter_inserts_separator_string_between_two_numbers_example(): assert list(utils.sep_inserter(iter([5, 9]), "")) == ["", 5, "", 9]
def test_sep_inserter_does_nothing_if_only_one_number_example(): assert list(utils.sep_inserter(iter(["a", 5]), "")) == ["a", 5]
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"]