8000 Merge pull request #632 from itsmemattchung/issue/627 · kislyuk/github3.py@7ebca53 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7ebca53

Browse files
authored
Merge pull request sigmavirus24#632 from itsmemattchung/issue/627
Raise exception for instance_or_null
2 parents 008cb11 + 1322fc8 commit 7ebca53

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

github3/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _instance_or_null(self, instance_class, json):
143143
if json is None:
144144
return NullObject(instance_class.__name__)
145145
if not isinstance(json, dict):
146-
return exceptions.UnprocessableResponseBody(
146+
raise exceptions.UnprocessableResponseBody(
147147
"GitHub's API returned a body that could not be handled", json
148148
)
149149
try:

tests/unit/test_models.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ def test_from_json(self):
107107
github_core = GitHubCore.from_json('{}')
108108
assert isinstance(github_core, GitHubCore)
109109

110+
def test_instance_or_null(self):
111+
"""Verify method raises exception when json is not a dict."""
112+
with pytest.raises(exceptions.UnprocessableResponseBody):
113+
self.instance._instance_or_null(GitHubCore, [])
114+
110115
def test_json(self):
111116
"""Verify JSON information is retrieved correctly."""
112117
response = requests.Response()

0 commit comments

Comments
 (0)
0