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

Function test_patch_create_from_blobs

test/test_patch_encoding.py:58–75  ·  view source on GitHub ↗
(encodingrepo: Repository)

Source from the content-addressed store, hash-verified

56
57
58def test_patch_create_from_blobs(encodingrepo: Repository) -> None:
59 old_content = encodingrepo['e84e339ac7fcc823106efa65a6972d7a20016c85']
60 new_content = encodingrepo['201e0c908e3d9f526659df3e556c3d06384ef0df']
61 assert isinstance(old_content, Blob)
62 assert isinstance(new_content, Blob)
63 patch = pygit2.Patch.create_from(
64 old_content,
65 new_content,
66 old_as_path='iso-8859-1.txt',
67 new_as_path='iso-8859-1.txt',
68 )
69
70 assert patch.data == expected_diff
71 assert patch.text == expected_diff.decode('utf-8', errors='replace')
72
73 # `patch.text` corrupted the ISO-8859-1 content as it forced UTF-8
74 # decoding, so assert that we cannot get the original content back:
75 assert patch.text.encode('utf-8') != expected_diff

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…