File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 4646
4747class ObjectTest (utils .RepoTestCase ):
4848
49+ def test_equality (self ):
50+ # get a commit object twice and see if it equals itself
51+ commit_id = self .repo .lookup_reference ('refs/heads/master' ).target
52+ commit_a = self .repo [commit_id ]
53+ commit_b = self .repo [commit_id ]
54+
55+ assert commit_a is not commit_b
56+ assert commit_a == commit_b
57+ assert not (commit_a != commit_b )
58+
59+ def test_hashing (self ):
60+ # get a commit object twice and compare hashes
61+ commit_id = self .repo .lookup_reference ('refs/heads/master' ).target
62+ commit_a = self .repo [commit_id ]
63+ commit_b = self .repo [commit_id ]
64+
65+ assert hash (commit_a )
66+
67+ assert commit_a is not commit_b
68+ assert commit_a == commit_b
69+ # if the commits are equal then their hash *must* be equal
70+ # but different objects can have the same commit
71+ assert hash (commit_a ) == hash (commit_b )
72+
73+ # sanity check that python container types work as expected
74+ s = set ()
75+ s .add (commit_a )
76+ s .add (commit_b )
77+ assert len (s ) == 1
78+ assert commit_a in s
79+ assert commit_b in s
80+
81+ d = {}
82+ d [commit_a ] = True
83+ assert commit_b in d
84+ assert d [commit_b ]
85+
86+ l = [commit_a ]
87+ assert commit_b in l
88+
4989 def test_peel_commit (self ):
5090 # start by looking up the commit
5191 commit_id = self .repo .lookup_reference ('refs/heads/master' ).target
You can’t perform that action at this time.
0 commit comments