Example #1
0
def test_patch_win_source_unix_patch(patch_files, testing_config):
    _ensure_win_line_endings('file-modification.txt')
    _ensure_unix_line_endings(patch_files)
    apply_patch('.', patch_files, testing_config)
    with open('file-modification.txt', 'r') as modified:
        lines = modified.readlines()
    assert lines[0] == '43770\n'
Example #2
0
def test_patch_win_source_unix_patch(patch_files, testing_config):
    _ensure_win_line_endings('file-modification.txt')
    _ensure_unix_line_endings(patch_files)
    apply_patch('.', patch_files, testing_config)
    with open('file-modification.txt', 'r') as modified:
        lines = modified.readlines()
    assert lines[0] == '43770\n'
Example #3
0
def test_ensure_unix_line_endings_with_nonutf8_characters():
    in_path = tempfile.mktemp()
    with open(in_path, "wb") as fp:
        fp.write(b"\xf1\r\n")  # tilde-n encoded in latin1

    out_path = _ensure_unix_line_endings(in_path)
    with open(out_path, "rb") as fp:
        assert fp.read() == b"\xf1\n"

    os.remove(in_path)
    os.remove(out_path)
Example #4
0
def test_ensure_unix_line_endings_with_nonutf8_characters():
    in_path = tempfile.mktemp()
    with open(in_path, "wb") as fp:
        fp.write(b"\xf1\r\n")  # tilde-n encoded in latin1

    out_path = _ensure_unix_line_endings(in_path)
    with open(out_path, "rb") as fp:
        assert fp.read() == b"\xf1\n"

    os.remove(in_path)
    os.remove(out_path)