File tree Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Expand file tree Collapse file tree 4 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -206,6 +206,12 @@ def _update_attributes(self, tree):
206
206
def _repr (self ):
207
207
return '<Tree [{0}]>' .format (self .sha )
208
208
209
+ def __eq__ (self , other ):
210
+ return self .as_dict () == other .as_dict ()
211
+
212
+ def __ne__ (self , other ):
213
+ return self .as_dict () != other .as_dict ()
214
+
209
215
def recurse (self ):
210
216
"""Recurse into the tree.
211
217
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -7,6 +7,17 @@ class TestTree(IntegrationHelper):
7
7
8
8
"""Integration tests for methods on the Test class."""
9
9
10
+ def test_inequality (self ):
11
+ """Test that a tree and its recursed tree are not equal."""
12
+ cassette_name = self .cassette_name ('ne' )
13
+ with self .recorder .use_cassette (cassette_name ):
14
+ repository = self .gh .repository ('sigmavirus24' , 'github3.py' )
15
+ tree = repository .tree (
16
+ '96726db07528a87b7c1f266ed42cd321070470c2'
17
+ )
18
+ recursed = tree .recurse ()
19
+ assert tree != recursed
20
+
10
21
def test_recurse (self ):
11
22
"""Test recurse on tree"""
12
23
cassette_name = self .cassette_name ('recurse' )
Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ class TestTree(UnitHelper):
20
20
described_class = github3 .git .Tree
21
21
example_data = get_example_data ()
22
22
23
+ def test_eq (self ):
24
+ """Assert that two trees are equal."""
25
+ tree = github3 .git .Tree (get_example_data ())
26
+ assert self .instance == tree
27
+
28
+ def test_ne (self ):
29
+ """Assert that two trees are not equal."""
30
+ tree = github3 .git .Tree (get_example_data ())
31
+ tree ._json_data ['truncated' ] = True
32
+ assert self .instance != tree
33
+
23
34
def test_repr (self ):
24
35
"""Assert Tree in in the repr."""
25
36
assert isinstance (self .instance , github3 .git .Tree )
@@ -36,7 +47,7 @@ def test_recurse(self):
36
47
37
48
class TestCommit (UnitHelper ):
38
49
39
- "Commit unit test." ""
50
+ """ Commit unit test."""
40
51
41
52
described_class = github3 .git .Commit
42
53
example_data = get_commit_example_data ()
You can’t perform that action at this time.
0 commit comments