def test_lstat(testrepo, get_path, path, mode, size, exception, expected_hex): path = get_path('HEAD', path) if exception: expected_hex = None else: if expected_hex: expected_hex = binascii.unhexlify(expected_hex) else: expected_hex = testrepo[hex_oid(path)].id.raw check_stat(path.lstat, mode, expected_hex, size, exception)
def test_joinpath_absolute_path(testrepo, get_path): path = get_path('HEAD', 'dir').joinpath(Path('/dir/file')) assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_joinpath_multiple(testrepo, get_path): path = get_path().joinpath('dir', 'file') assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_joinpath_pathlib(testrepo, get_path): path = get_path().joinpath(Path('dir/file')) assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_slash_absolute_str(testrepo, get_path): path = get_path('HEAD', 'dir') / '/dir/file' assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_joinpath(testrepo, get_path): path = get_path().joinpath('dir') assert hex_oid(path) == testrepo.revparse_single('HEAD:dir').hex
def test_slash_combined(testrepo, get_path): path = get_path() / 'dir/file' assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_slash_pathlib(testrepo, get_path): path = get_path() / Path('dir/file') assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_slash_multiple(testrepo, get_path): path = get_path() / 'dir' / 'file' assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_slash(testrepo, get_path): path = get_path() / 'dir' assert hex_oid(path) == testrepo.revparse_single('HEAD:dir').hex
def test_components(testrepo, get_path): path = get_path('HEAD', 'dir', 'file') assert hex_oid(path) == testrepo.revparse_single('HEAD:dir/file').hex
def test_parent(testrepo, get_path): path = get_path('HEAD^') parent = testrepo.head.peel(pygit2.Commit).parents[0] assert hex_oid(path) == parent.peel(pygit2.Tree).hex
def test_head(testrepo, get_path): path = get_path() assert hex_oid(path) == testrepo.head.peel(pygit2.Tree).hex