| 51 | |
| 52 | |
| 53 | def 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 | |
| 83 | def test_peel_commit(testrepo: Repository) -> None: |