Skip to content

Commit 1dbd591

Browse files
committed
This commit should fix the failing tests.
1 parent ed5fcdc commit 1dbd591

2 files changed

Lines changed: 34 additions & 12 deletions

File tree

github3/git.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, commit, session=None):
8383
self.tree = Tree(commit.get('tree'), self._session)
8484

8585
def __repr__(self):
86-
return '<Commit [{0}:{1}]>'.format(self.author.name, self._sha)
86+
return '<Commit [{0}:{1}]>'.format(self.author.name, self.sha)
8787

8888

8989
class Reference(GitHubCore):
@@ -154,7 +154,7 @@ def __init__(self, tag):
154154
self.object = GitObject(tag.get('object'))
155155

156156
def __repr__(self):
157-
return '<Tag [{0}]>'.format(self._tag)
157+
return '<Tag [{0}]>'.format(self.tag)
158158

159159

160160
class Tree(GitData):
@@ -165,15 +165,15 @@ def __init__(self, tree, session=None):
165165
self.tree = [Hash(t) for t in tree.get('tree', [])]
166166

167167
def __repr__(self):
168-
return '<Tree [{0}]>'.format(self._sha)
168+
return '<Tree [{0}]>'.format(self.sha)
169169

170170
def recurse(self):
171171
"""Recurse into the tree.
172172
173173
:returns: :class:`Tree <Tree>`
174174
"""
175-
url = self._api + '?recursive=1'
176-
json = self._json(self._get(url), 200)
175+
json = self._json(self._get(self._api, params={'recursive': '1'}),
176+
200)
177177
return Tree(json, self._session) if json else None
178178

179179

tests/test_git.py

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,34 @@ def test_sha(self):
3535
def test_size(self):
3636
expect_str(self.blob.size)
3737

38+
39+
class TestCommit(BaseTest):
40+
def __init__(self, methodName='runTest'):
41+
r = self.g.repository(self.sigm, self.todo)
42+
self.commit = r.git_commit('8b0704374914f03a54b89d938de1c09d5831824e')
43+
3844
def test_commit(self):
39-
r = self.todor
40-
commit = r.git_commit('8b0704374914f03a54b89d938de1c09d5831824e')
41-
expect(commit).isinstance(Commit)
42-
self.assertAreNotNone(commit, 'author', 'committer', 'tree', 'message',
43-
'parents', 'sha')
45+
expect(self.commit).isinstance(Commit)
46+
expect_str(repr(self.commit))
47+
48+
def test_author(self):
49+
expect(self.commit.author).is_not_None()
50+
51+
def test_committer(self):
52+
expect(self.commit.author).is_not_None()
53+
54+
def test_tree(self):
55+
expect(self.commit.tree).isinstance(Tree)
56+
57+
def test_message(self):
58+
expect_str(self.commit.message)
59+
60+
def test_parents(self):
61+
expect(self.commit.parents).isinstance(list)
62+
self.expect_list_of_class(self.commit.parents, dict)
63+
64+
def test_sha(self):
65+
expect_str(self.commit.sha)
4466

4567

4668
class TestTag(BaseTest):
@@ -74,6 +96,8 @@ def __init__(self, methodName='runTest'):
7496
super(TestTreeHash, self).__init__(methodName)
7597
r = self.g.repository(self.sigm, self.todo)
7698
self.tree = r.tree('31e862095dffa60744f1ce16a431ea040381f053')
99+
self.hashes = self.tree.tree
100+
self.hash = self.hashes[0]
77101

78102
def test_tree(self):
79103
expect(self.tree).isinstance(Tree)
@@ -86,10 +110,8 @@ def test_tree_recurse(self):
86110
expect(self.tree.recurse()).isinstance(Tree)
87111

88112
def test_hash(self):
89-
self.hashes = self.tree.tree
90113
for h in self.hashes:
91114
expect(h).isinstance(Hash)
92-
self.hash = self.hashes[0]
93115

94116
def test_hash_mode(self):
95117
expect_str(self.hash.mode)

0 commit comments

Comments
 (0)