[lang-ref] ( file_input_line_one_by_one ) ( python )

def test_file_input_line_one_by_one(tmp_path):
    # f.read()
    lines = ['test message %03d\n' % x for x in range(5)]
    text  = ''.join(lines)
    p = tmp_path / 'a.txt'

    with p.open('w') as f:
        f.write(text)

    with p.open() as f:
        lines_new = []
        for line in f:
            lines_new.append(line)

    assert lines_new == lines