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

Function test_create_blob

test/test_blob.py:96–117  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

94
95
96def test_create_blob(testrepo: Repository) -> None:
97 blob_oid = testrepo.create_blob(BLOB_NEW_CONTENT)
98 blob = testrepo[blob_oid]
99
100 assert isinstance(blob, pygit2.Blob)
101 assert ObjectType.BLOB == blob.type
102
103 assert blob_oid == blob.id
104 assert utils.gen_blob_sha1(BLOB_NEW_CONTENT) == blob_oid
105
106 assert BLOB_NEW_CONTENT == blob.data
107 assert len(BLOB_NEW_CONTENT) == blob.size
108 assert BLOB_NEW_CONTENT == blob.read_raw()
109 blob_buffer = memoryview(blob)
110 assert len(BLOB_NEW_CONTENT) == len(blob_buffer)
111 assert BLOB_NEW_CONTENT == blob_buffer
112
113 def set_content() -> None:
114 blob_buffer[:2] = b'hi'
115
116 with pytest.raises(TypeError):
117 set_content()
118
119
120def test_create_blob_fromworkdir(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 1

set_contentFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…