MCPcopy Create free account
hub / github.com/libgit2/pygit2 / test_patch_from_non_utf8

Function test_patch_from_non_utf8

test/test_patch_encoding.py:39–55  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

37
38
39def test_patch_from_non_utf8() -> None:
40 # blobs encoded in ISO-8859-1
41 old_content = b'Kristian H\xf8gsberg\n'
42 new_content = old_content + b'foo\n'
43 patch = pygit2.Patch.create_from(
44 old_content,
45 new_content,
46 old_as_path='iso-8859-1.txt',
47 new_as_path='iso-8859-1.txt',
48 )
49
50 assert patch.data == expected_diff
51 assert patch.text == expected_diff.decode('utf-8', errors='replace')
52
53 # `patch.text` corrupted the ISO-8859-1 content as it forced UTF-8
54 # decoding, so assert that we cannot get the original content back:
55 assert patch.text.encode('utf-8') != expected_diff
56
57
58def test_patch_create_from_blobs(encodingrepo: Repository) -> None:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…