11import github3
2- from mock import patch , Mock
3- from tests .utils import (BaseCase , load )
2+ from tests .utils import (BaseCase , load , mock )
43
54
65def merge (first , second = None , ** kwargs ):
@@ -20,7 +19,7 @@ def test_init(self):
2019
2120 def test_context_manager (self ):
2221 with github3 .GitHub () as gh :
23- gh .__exit__ = Mock ()
22+ gh .__exit__ = mock . Mock ()
2423 assert isinstance (gh , github3 .GitHub )
2524
2625 gh .__exit__ .assert_called ()
@@ -92,7 +91,7 @@ def test_create_issue(self):
9291 assert i is None
9392 assert self .request .called is False
9493
95- with patch .object (github3 .GitHub , 'repository' ) as repo :
94+ with mock . patch .object (github3 .GitHub , 'repository' ) as repo :
9695 repo .return_value = github3 .repos .Repository (
9796 load ('repo' ), self .g )
9897 i = self .g .create_issue ('user' , 'repo' , 'Title' )
@@ -125,7 +124,7 @@ def test_delete_key(self):
125124 self .response (None , 204 )
126125
127126 self .login ()
128- with patch .object (github3 .github .GitHub , 'key' ) as key :
127+ with mock . patch .object (github3 .github .GitHub , 'key' ) as key :
129128 key .return_value = github3 .users .Key (load ('key' ), self .g )
130129 assert self .g .delete_key (10 ) is True
131130 key .return_value = None
@@ -216,7 +215,7 @@ def test_issue(self):
216215 'issues/1' )
217216
218217 assert self .g .issue (None , None , 0 ) is None
219- with patch .object (github3 .github .GitHub , 'repository' ) as repo :
218+ with mock . patch .object (github3 .github .GitHub , 'repository' ) as repo :
220219 repo .return_value = github3 .repos .Repository (load ('repo' ))
221220 i = self .g .issue ('user' , 'repo' , 1 )
222221
@@ -315,7 +314,7 @@ def test_iter_followers(self):
315314
316315 self .assertRaises (github3 .GitHubError , self .g .iter_followers )
317316
318- with patch .object (github3 .github .GitHub , 'user' ) as ghuser :
317+ with mock . patch .object (github3 .github .GitHub , 'user' ) as ghuser :
319318 ghuser .return_value = github3 .users .User (load ('user' ))
320319 u = next (self .g .iter_followers ('sigmavirus24' ))
321320 assert isinstance (u , github3 .users .User )
@@ -337,7 +336,7 @@ def test_iter_following(self):
337336 self .assertRaises (github3 .GitHubError , self .g .iter_following )
338337 assert self .request .called is False
339338
340- with patch .object (github3 .github .GitHub , 'user' ) as ghuser :
339+ with mock . patch .object (github3 .github .GitHub , 'user' ) as ghuser :
341340 ghuser .return_value = github3 .users .User (load ('user' ))
342341 u = next (self .g .iter_following ('sigmavirus24' ))
343342 assert isinstance (u , github3 .users .User )
@@ -453,7 +452,7 @@ def test_iter_repo_issues(self):
453452 self .get ('https://api.github.com/repos/sigmavirus24/github3.py/'
454453 'issues' )
455454
456- with patch .object (github3 .GitHub , 'repository' ) as repo :
455+ with mock . patch .object (github3 .GitHub , 'repository' ) as repo :
457456 repo .return_value = github3 .repos .Repository (load ('repo' ),
458457 self .g )
459458 i = next (self .g .iter_repo_issues ('sigmavirus24' , 'github3.py' ))
@@ -546,7 +545,7 @@ def test_iter_starred(self):
546545 github3 .repos .Repository )
547546 self .mock_assertions ()
548547
549- with patch .object (github3 .github .GitHub , 'user' ) as user :
548+ with mock . patch .object (github3 .github .GitHub , 'user' ) as user :
550549 user .return_value = github3 .users .User (load ('user' ))
551550 self .get ('https://api.github.com/users/sigmavirus24/starred' )
552551 assert isinstance (next (self .g .iter_starred ('sigmavirus24' )),
@@ -563,7 +562,7 @@ def test_iter_subscriptions(self):
563562 github3 .repos .Repository )
564563 self .mock_assertions ()
565564
566- with patch .object (github3 .github .GitHub , 'user' ) as user :
565+ with mock . patch .object (github3 .github .GitHub , 'user' ) as user :
567566 user .return_value = github3 .users .User (load ('user' ))
568567 self .get ('https://api.github.com/users/sigmavirus24/'
569568 'subscriptions' )
@@ -663,7 +662,7 @@ def test_pull_request(self):
663662 'github3.py/pulls/18' )
664663 pr = None
665664
666- with patch .object (github3 .github .GitHub , 'repository' ) as repo :
665+ with mock . patch .object (github3 .github .GitHub , 'repository' ) as repo :
667666 repo .return_value = github3 .repos .Repository (load ('repo' ))
668667 pr = self .g .pull_request ('sigmavirus24' , 'github3.py' , 18 )
669668
@@ -766,8 +765,8 @@ def test_update_user(self):
766765 args = (
'Ian Cordasco' ,
'[email protected] ' ,
'www.blog.com' ,
'company' ,
767766 'loc' , True , 'bio' )
768767
769- with patch .object (github3 .github .GitHub , 'user' ) as user :
770- 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 :
771770 user .return_value = github3 .users .User (load ('user' ), self .g )
772771 upd .return_value = True
773772 assert self .g .update_user (* args )
0 commit comments