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

Function test_repository_hashfile

test/test_repository.py:996–1016  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

994
995
996def test_repository_hashfile(testrepo: Repository) -> None:
997 original_hash = testrepo.index['hello.txt'].id
998
999 # Test simple use
1000 h = testrepo.hashfile('hello.txt')
1001 assert h == original_hash
1002
1003 # Test absolute path
1004 # For best results on Windows, pass a pure POSIX path. (See https://github.com/libgit2/libgit2/issues/6825)
1005 absolute_path = Path(testrepo.workdir, 'hello.txt')
1006 absolute_path_str = absolute_path.as_posix() # Windows compatibility
1007 h = testrepo.hashfile(str(absolute_path_str))
1008 assert h == original_hash
1009
1010 # Test missing path
1011 with pytest.raises(KeyError):
1012 testrepo.hashfile('missing-file')
1013
1014 # Test invalid object type
1015 with pytest.raises(pygit2.GitError):
1016 testrepo.hashfile('hello.txt', ObjectType.OFS_DELTA)
1017
1018
1019def test_repository_hashfile_filter(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 1

hashfileMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…