Exemplo n.º 1
0
def test_replace_not_found(expand_path_fixtures):
    count_replaced = transforms.replace(["a.txt", "b.py"], r"z", r"q")
    assert 0 == count_replaced
    assert "alpha text" == open("a.txt", "rt").read()
    assert "beta python" == open("b.py", "rt").read()
Exemplo n.º 2
0
def test_simple_replace(expand_path_fixtures):
    count_replaced = transforms.replace(["a.txt", "b.py"], "b..a", "GA")
    assert 1 == count_replaced
    assert "alpha text" == open("a.txt", "rt").read()
    assert "GA python" == open("b.py", "rt").read()
Exemplo n.º 3
0
def test_multi_replace(expand_path_fixtures):
    count_replaced = transforms.replace(["a.txt", "b.py"], r"(\w+)a", r"\1z")
    assert 2 == count_replaced
    assert "alphz text" == open("a.txt", "rt").read()
    assert "betz python" == open("b.py", "rt").read()
Exemplo n.º 4
0
def test_replace_one_path(expand_path_fixtures):
    # Lots of synth.py files pass a single Path as the first argument.
    count_replaced = transforms.replace(pathlib.Path("*.py"), "b..a", "GA")
    assert 1 == count_replaced
    assert "GA python" == open("b.py", "rt").read()