8000 Make Repository#create_file more defensive · pythonthings/github3.py@5c61661 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5c61661

Browse files
committed
Make Repository#create_file more defensive
Do not mock the response from the API in unit tests
1 parent 1536962 commit 5c61661

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

github3/repos/repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ def create_file(self, path, message, content, branch=None,
743743
'author': validate_commmitter(author)}
744744
self._remove_none(data)
745745
json = self._json(self._put(url, data=dumps(data)), 201)
746-
if 'content' in json and 'commit' in json:
746+
if json and 'content' in json and 'commit' in json:
747747
json['content'] = Contents(json['content'], self)
748748
json['commit'] = Commit(json['commit'], self)
749749
return json

tests/unit/test_repos_repo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ def test_create_file(self):
7878
}
7979
}
8080

81-
with mock.patch.object(GitHubCore, '_json') as _json:
82-
_json.return_value = create_file_contents_example_data
83-
self.instance.create_file(**data)
81+
self.instance.create_file(**data)
8482

8583
b64_encoded_content = b64encode(data['content']).decode('utf-8')
8684
data.update({

0 commit comments

Comments
 (0)
0