8000 Update references to mock in api tests · jpulec/github3.py@92e6f82 · GitHub
[go: up one dir, main page]

Skip to content

Commit 92e6f82

Browse files
committed
Update references to mock in api tests
1 parent f04cc80 commit 92e6f82

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

tests/test_api.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import github3
22
from unittest import TestCase
3-
try:
4-
from unittest.mock import patch, NonCallableMock
5-
except ImportError:
6-
from mock import patch, NonCallableMock
3+
#from .utils.mock import patch, NonCallableMock
4+
from .utils import mock
75

86

97
class TestAPI(TestCase):
108
def setUp(self):
11-
self.mock = patch('github3.api.gh', autospec=github3.GitHub)
9+
self.mock = mock.patch('github3.api.gh', autospec=github3.GitHub)
1210
self.gh = self.mock.start()
1311

1412
def tearDown(self):
@@ -17,21 +15,21 @@ def tearDown(self):
1715
def test_authorize(self):
1816
args = ('login', 'password', ['scope1'], 'note', 'note_url.com', '',
1917
'')
20-
with patch.object(github3.api.GitHub, 'authorize') as authorize:
18+
with mock.patch.object(github3.api.GitHub, 'authorize') as authorize:
2119
github3.authorize(*args)
2220
authorize.assert_called_once_with(*args)
2321

2422
def test_login(self):
2523
args = ('login', 'password', None, None)
26-
with patch.object(github3.api.GitHub, 'login') as login:
24+
with mock.patch.object(github3.api.GitHub, 'login') as login:
2725
g = github3.login(*args)
2826
assert isinstance(g, github3.github.GitHub)
2927
assert not isinstance(g, github3.github.GitHubEnterprise)
3028
login.assert_called_with(*args)
3129

3230
def test_enterprise_login(self):
3331
args = ('login', 'password', None, 'http://ghe.invalid/', None)
34-
with patch.object(github3.api.GitHubEnterprise, 'login') as login:
32+
with mock.patch.object(github3.api.GitHubEnterprise, 'login') as login:
3533
g = github3.login(*args)
363 75DF 4
assert isinstance(g, github3.github.GitHubEnterprise)
3735
login.assert_called_with('login', 'password', None, None)
@@ -146,7 +144,7 @@ def test_rate_limit(self):
146144
def test_ratelimit_remaining(self):
147145
# This prevents a regression in the API
148146
# See 81c800658db43f86419b9c0764fc16aad3d60007
149-
self.gh.ratelimit_remaining = NonCallableMock()
147+
self.gh.ratelimit_remaining = mock.NonCallableMock()
150148
github3.ratelimit_remaining()
151149

152150
def test_zen(self):

0 commit comments

Comments
 (0)
0