1616# You should have received a copy of the GNU Lesser General Public License
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19- from __future__ import print_function
20-
2119import os
2220import pickle
2321import tempfile
2422import json
25-
26- try :
27- import unittest
28- except ImportError :
29- import unittest2 as unittest
23+ import unittest
3024
3125from httmock import HTTMock # noqa
3226from httmock import response # noqa
@@ -479,7 +473,7 @@ def resp_cont(url, request):
479473 self .gl .auth ()
480474 self .assertEqual (self .gl .user .username , name )
481475 self .assertEqual (self .gl .user .id , id_ )
482- self .assertEqual ( type ( self .gl .user ) , CurrentUser )
476+ self .assertIsInstance ( self .gl .user , CurrentUser )
483477
484478 def test_hooks (self ):
485479 @urlmatch (
@@ -492,7 +486,7 @@ def resp_get_hook(url, request):
492486
493487 with HTTMock (resp_get_hook ):
494488 data = self .gl .hooks .get (1 )
495- self .assertEqual ( type ( data ) , Hook )
489+ self .assertIsInstance ( data , Hook )
496490 self .assertEqual (data .url , "testurl" )
497491 self .assertEqual (data .id , 1 )
498492
@@ -507,7 +501,7 @@ def resp_get_project(url, request):
507501
508502 with HTTMock (resp_get_project ):
509503 data = self .gl .projects .get (1 )
510- self .assertEqual ( type ( data ) , Project )
504+ self .assertIsInstance ( data , Project )
511505 self .assertEqual (data .name , "name" )
512506 self .assertEqual (data .id , 1 )
513507
@@ -553,7 +547,7 @@ def resp_get_group(url, request):
553547
554548 with HTTMock (resp_get_group ):
555549 data = self .gl .groups .get (1 )
556- self .assertEqual ( type ( data ) , Group )
550+ self .assertIsInstance ( data , Group )
557551 self .assertEqual (data .name , "name" )
558552 self .assertEqual (data .path , "path" )
559553 self .assertEqual (data .id , 1 )
@@ -586,7 +580,7 @@ def resp_get_user(self, url, request):
586580 def test_users (self ):
587581 with HTTMock (self .resp_get_user ):
588582 user = self .gl .users .get (1 )
589- self .assertEqual ( type ( user ) , User )
583+ self .assertIsInstance ( user , User )
590584 self .assertEqual (user .name , "name" )
591585 self .assertEqual (user .id , 1 )
592586
@@ -607,7 +601,7 @@ def resp_get_user_status(url, request):
607601 user = self .gl .users .get (1 )
608602 with HTTMock (resp_get_user_status ):
609603 status = user .status .get ()
610- self .assertEqual ( type ( status ) , UserStatus )
604+ self .assertIsInstance ( status , UserStatus )
611605 self .assertEqual (status .message , "test" )
612606 self .assertEqual (status .emoji , "thumbsup" )
613607
@@ -636,7 +630,7 @@ def resp_mark_as_done(url, request):
636630
637631 with HTTMock (resp_get_todo ):
638632 todo = self .gl .todos .list ()[0 ]
639- self .assertEqual ( type ( todo ) , Todo )
633+ self .assertIsInstance ( todo , Todo )
640634 self .assertEqual (todo .id , 102 )
641635 self .assertEqual (todo .target_type , "MergeRequest" )
642636 self .assertEqual (todo .target ["assignee" ]["username" ], "root" )
@@ -683,10 +677,10 @@ def resp_update_submodule(url, request):
683677 "committer_name": "Author",
684678 "committer_email": "author@example.com",
685679 "created_at": "2018-09-20T09:26:24.000-07:00",
686- "message": "Message",
687- "parent_ids": [ "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" ],
680+ "message": "Message",
681+ "parent_ids": [ "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" ],
688682 "committed_date": "2018-09-20T09:26:24.000-07:00",
689- "authored_date": "2018-09-20T09:26:24.000-07:00",
683+ "authored_date": "2018-09-20T09:26:24.000-07:00",
690684 "status": null}"""
691685 content = content .encode ("utf-8" )
692686 return response (200 , content , headers , None , 5 , request )
@@ -724,5 +718,5 @@ class MyGitlab(gitlab.Gitlab):
724718
725719 config_path = self ._default_config ()
726720 gl = MyGitlab .from_config ("one" , [config_path ])
727- self .assertEqual ( type ( gl ). __name__ , " MyGitlab" )
721+ self .assertIsInstance ( gl , MyGitlab )
728722 os .unlink (config_path )
0 commit comments