(testrepo: Repository)
| 994 | |
| 995 | |
| 996 | def 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 | |
| 1019 | def test_repository_hashfile_filter(testrepo: Repository) -> None: |
nothing calls this directly
no test coverage detected
searching dependent graphs…