Skip to content

Commit aea20f5

Browse files
committed
Fix python3 tests and the test error.
Apparently author isn't always present. Interesting.
1 parent ced6d55 commit aea20f5

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

github3/decorators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from StringIO import StringIO
1515
except ImportError:
1616
# python3
17-
from io import StringIO
17+
from io import BytesIO as StringIO
1818

1919

2020
def requires_auth(func):
@@ -42,6 +42,7 @@ def auth_wrapper(self, *args, **kwargs):
4242
# Mock a 401 response
4343
r = Response()
4444
r.status_code = 401
45-
r.raw = StringIO('{"message": "Requires authentication"}')
45+
r.encoding = 'utf-8'
46+
r.raw = StringIO('{"message": "Requires authentication"}'.encode())
4647
raise GitHubError(r)
4748
return auth_wrapper

github3/git.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,12 @@ def __init__(self, commit, session=None):
6060

6161
#: dict containing at least the name, email and date the commit was
6262
# created
63-
self.author = commit.get('author')
63+
self.author = commit.get('author', {})
6464
self._author_name = self.author.get('name', '')
6565

6666
#: dict containing similar information to the author attribute
67-
self.committer = commit.get('committer')
68-
if commit.get('committer'):
69-
self.committer = User(commit.get('committer'), None)
67+
self.committer = commit.get('committer', {})
68+
self._commit_name = self.committer.get('name', '')
7069

7170
#: :class:`Tree <Tree>` the commit belongs to.
7271
self.tree = None

0 commit comments

Comments
 (0)