Ejemplo n.º 1
0
def try_on_file(filename: str):
    """ Given a file name (something.py) find this file in test/integration/samples_in,
    run flint_str on its content, write result to test/integration/actual_out/something.py,
    and compare the result with test/integration/expected_out/something.py"""
    txt_in = read_in(filename)
    result_path = write_output_file(filename, txt_in)

    fstringify_file(result_path, multiline=True, len_limit=79, pyup=True)

    with open(result_path) as f:
        out = f.read()

    return out, read_expected(filename)
Ejemplo n.º 2
0
def test_py2(py2_file):

    with open(py2_file) as f:
        content_before = f.read()

    modified, _, _, _ = fstringify_file(py2_file, True, 1000)

    with open(py2_file) as f:
        content_after = f.read()

    assert not modified
    assert content_after == content_before
Ejemplo n.º 3
0
def test_works(formattable_file):

    with open(formattable_file) as f:
        content_before = f.read()

    modified, _, _, _ = fstringify_file(formattable_file, True, 1000)

    with open(formattable_file) as f:
        content_after = f.read()

    assert modified
    assert content_after != content_before
Ejemplo n.º 4
0
def test_pyup_trivia(pyup_file):

    with open(pyup_file) as f:
        content_before = f.read()

    modified, _, _, _ = fstringify_file(pyup_file, True, 1000, pyup=True)

    with open(pyup_file) as f:
        content_after = f.read()

    assert modified
    assert content_after != content_before
Ejemplo n.º 5
0
def test_catches_subtle(formattable_file, monkeypatch):

    with open(formattable_file) as f:
        content_before = f.read()

    def broken_fstringify_by_line(*args, **kwargs):
        return "a = 42", 42

    monkeypatch.setattr(api, "fstringify_code_by_line",
                        broken_fstringify_by_line)

    modified, _, _, _ = fstringify_file(formattable_file, True, 1000)

    with open(formattable_file) as f:
        content_after = f.read()

    assert not modified
    assert content_after == content_before