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

Function test_hashing

test/test_object.py:53–80  ·  view source on GitHub ↗
(testrepo: Repository)

Source from the content-addressed store, hash-verified

51
52
53def test_hashing(testrepo: Repository) -> None:
54 # get a commit object twice and compare hashes
55 commit_id = testrepo.lookup_reference('refs/heads/master').target
56 commit_a = testrepo[commit_id]
57 commit_b = testrepo[commit_id]
58
59 assert hash(commit_a)
60
61 assert commit_a is not commit_b
62 assert commit_a == commit_b
63 # if the commits are equal then their hash *must* be equal
64 # but different objects can have the same commit
65 assert hash(commit_a) == hash(commit_b)
66
67 # sanity check that python container types work as expected
68 s = set()
69 s.add(commit_a)
70 s.add(commit_b)
71 assert len(s) == 1
72 assert commit_a in s
73 assert commit_b in s
74
75 d = {}
76 d[commit_a] = True
77 assert commit_b in d
78 assert d[commit_b]
79
80 assert commit_b == commit_a
81
82
83def test_peel_commit(testrepo: Repository) -> None:

Callers

nothing calls this directly

Calls 2

hashFunction · 0.85
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…