Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7ebca53

Browse files
authored
Merge pull requestsigmavirus24#632 from itsmemattchung/issue/627
Raise exception for instance_or_null
2 parents008cb11 +1322fc8 commit7ebca53

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
ifjsonisNone:
144144
returnNullObject(instance_class.__name__)
145145
ifnotisinstance(json,dict):
146-
returnexceptions.UnprocessableResponseBody(
146+
raiseexceptions.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
assertisinstance(github_core,GitHubCore)
109109

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp