[lang-ref] ( file_compare ) ( python )

def test_file_compare(tmp_path):
    # filecmp.cmp(a, b)
    lines = ['test message %03d\n' % x for x in range(5)]
    text  = ''.join(lines)
    p1 = tmp_path / 'a1.txt'
    p2 = tmp_path / 'a2.txt'

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

    with p2.open('w') as f:
        f.writelines(lines)

    import filecmp
    assert filecmp.cmp(p1, p2, shallow=False) is True