8000 Update references to mock in GitHub tests · jhermann/github3.py@1ddbc73 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 1ddbc73

Browse files
committed
Update references to mock in GitHub tests
1 parent 92e6f82 commit 1ddbc73

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

tests/test_github.py

Lines changed: 13 additions & 17 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import github3
2-
try:
3-
from unittest.mock import patch, Mock
4-
except ImportError:
5-
from mock import patch, Mock
6-
from tests.utils import (BaseCase, load)
2+
from tests.utils import (BaseCase, load, mock)
73

84

95
def merge(first, second=None, **kwargs):
@@ -23,7 +19,7 @@ def test_init(self):
2319

2420
def test_context_manager(self):
2521
with github3.GitHub() as gh:
26-
gh.__exit__ = Mock()
22+
gh.__exit__ = mock.Mock()
2723
assert isinstance(gh, github3.GitHub)
2824

2925
gh.__exit__.assert_called()
@@ -95,7 +91,7 @@ def test_create_issue(self):
9591
assert i is None
9692
assert self.request.called is False
9793

98-
with patch.object(github3.GitHub, 'repository') as repo:
94+
with mock.patch.object(github3.GitHub, 'repository') as repo:
9995
repo.return_value = github3.repos.Repository(
10096
load('repo'), self.g)
10197
i = self.g.create_issue('user', 'repo', 'Title')
@@ -128,7 +124,7 @@ def test_delete_key(self):
128124
self.response(None, 204)
129125

130126
self.login()
131-
with patch.object(github3.github.GitHub, 'key') as key:
127+
with mock.patch.object(github3.github.GitHub, 'key') as key:
132128
key.return_value = github3.users.Key(load('key'), self.g)
133129
assert self.g.delete_key(10) is True
134130
key.return_value = None
@@ -219,7 +215,7 @@ def test_issue(self):
219215
'issues/1')
220216

221217
assert self.g.issue(None, None, 0) is None
222-
with patch.object(github3.github.GitHub, 'repository') as repo:
218+
with mock.patch.object(github3.github.GitHub, 'repository') as repo:
223219
repo.return_value = github3.repos.Repository(load('repo'))
224220
i = self.g.issue('user', 'repo', 1)
225221

@@ -318,7 +314,7 @@ def test_iter_followers(self):
318314

319315
self.assertRaises(github3.GitHubError, self.g.iter_followers)
320316

321-
with patch.object(github3.github.GitHub, 'user') as ghuser:
317+
with mock.patch.object(github3.github.GitHub, 'user') as ghuser:
322318
ghuser.return_value = github3.users.User(load('user'))
323319
u = next(self.g.iter_followers('sigmavirus24'))
324320
assert isinstance(u, github3.users.User)
@@ -340,7 +336,7 @@ def test_iter_following(self):
340336
self.assertRaises(github3.GitHubError, self.g.iter_following)
341337
assert self.request.called is False
342338

343-
with patch.object(github3.github.GitHub, 'user') as ghuser:
339+
with mock.patch.object(github3.github.GitHub, 'user') as ghuser:
344340
ghuser.return_value = github3.users.User(load('user'))
345341
u = next(self.g.iter_following('sigmavirus24'))
346342
assert isinstance(u, github3.users.User)
@@ -456,7 +452,7 @@ def test_iter_repo_issues(self):
456452
self.get('https://api.github.com/repos/sigmavirus24/github3.py/'
457453
'issues')
458454

459-
with patch.object(github3.GitHub, 'repository') as repo:
455+
with mock.patch.object(github3.GitHub, 'repository') as repo:
460456
repo.return_value = github3.repos.Repository(load('repo'),
461457
self.g)
462458
i = next(self.g.iter_repo_issues('sigmavirus24', 'github3.py'))
@@ -549,7 +545,7 @@ def test_iter_starred(self):
549545
github3.repos.Repository)
550546
self.mock_assertions()
551547

552-
with patch.object(github3.github.GitHub, 'user') as user:
548+
with mock.patch.object(github3.github.GitHub, 'user') as user:
553549
user.return_value = github3.users.User(load('user'))
554550
self.get('https://api.github.com/users/sigmavirus24/starred')
555551
assert isinstance(next(self.g.iter_starred('sigmavirus24')),
@@ -566,7 +562,7 @@ def test_iter_subscriptions(self):
566562
github3.repos.Repository)
567563
self.mock_assertions()
568564

569-
with patch.object(github3.github.GitHub, 'user') as user:
565+
with mock.patch.object(github3.github.GitHub, 'user') as user:
570566
user.return_value = github3.users.User(load('user'))
571567
self.get('https://api.github.com/users/sigmavirus24/'
572568
'subscriptions')
@@ -666,7 +662,7 @@ def test_pull_request(self):
666662
'github3.py/pulls/18')
667663
pr = None
668664

669-
with patch.object(github3.github.GitHub, 'repository') as repo:
665+
with mock.patch.object(github3.github.GitHub, 'repository') as repo:
670666
repo.return_value = github3.repos.Repository(load('repo'))
671667
pr = self.g.pull_request('sigmavirus24', 'github3.py', 18)
672668

@@ -769,8 +765,8 @@ def test_update_user(self):
769765
args = ('Ian Cordasco', 'example@mail.com', 'www.blog.com', 'company',
770766
'loc', True, 'bio')
771767

772-
with patch.object(github3.github.GitHub, 'user') as user:
773-
with patch.object(github3.users.User, 'update') as upd:
768+
with mock.patch.object(github3.github.GitHub, 'user') as user:
769+
with mock.patch.object(github3.users.User, 'update') as upd:
774770
user.return_value = github3.users.User(load('user'), self.g)
775771
upd.return_value = True
776772
assert self.g.update_user(*args)

0 commit comments

Comments
 (0)
0