16
16
# You should have received a copy of the GNU Lesser General Public License
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
- from __future__ import print_function
20
-
21
19
import os
22
20
import pickle
23
21
import tempfile
24
22
import json
25
-
26
- try :
27
- import unittest
28
- except ImportError :
29
- import unittest2 as unittest
23
+ import unittest
30
24
31
25
from httmock import HTTMock # noqa
32
26
from httmock import response # noqa
@@ -479,7 +473,7 @@ def resp_cont(url, request):
479
473
self .gl .auth ()
480
474
self .assertEqual (self .gl .user .username , name )
481
475
self .assertEqual (self .gl .user .id , id_ )
482
- self .assertEqual ( type ( self .gl .user ) , CurrentUser )
476
+ self .assertIsInstance ( self .gl .user , CurrentUser )
483
477
484
478
def test_hooks (self ):
485
479
@urlmatch (
@@ -492,7 +486,7 @@ def resp_get_hook(url, request):
492
486
493
487
with HTTMock (resp_get_hook ):
494
488
data = self .gl .hooks .get (1 )
495
- self .assertEqual ( type ( data ) , Hook )
489
+ self .assertIsInstance ( data , Hook )
496
490
self .assertEqual (data .url , "testurl" )
497
491
self .assertEqual (data .id , 1 )
498
492
@@ -507,7 +501,7 @@ def resp_get_project(url, request):
507
501
508
502
with HTTMock (resp_get_project ):
509
503
data = self .gl .projects .get (1 )
510
- self .assertEqual ( type ( data ) , Project )
504
+ self .assertIsInstance ( data , Project )
511
505
self .assertEqual (data .name , "name" )
512
506
self .assertEqual (data .id , 1 )
513
507
@@ -553,7 +547,7 @@ def resp_get_group(url, request):
553
547
554
548
with HTTMock (resp_get_group ):
555
549
data = self .gl .groups .get (1 )
556
- self .assertEqual ( type ( data ) , Group )
550
+ self .assertIsInstance ( data , Group )
557
551
self .assertEqual (data .name , "name" )
558
552
self .assertEqual (data .path , "path" )
559
553
self .assertEqual (data .id , 1 )
@@ -586,7 +580,7 @@ def resp_get_user(self, url, request):
586
580
def test_users (self ):
587
581
with HTTMock (self .resp_get_user ):
588
582
user = self .gl .users .get (1 )
589
- self .assertEqual ( type ( user ) , User )
583
+ self .assertIsInstance ( user , User )
590
584
self .assertEqual (user .name , "name" )
591
585
self .assertEqual (user .id , 1 )
592
586
@@ -607,7 +601,7 @@ def resp_get_user_status(url, request):
607
601
user = self .gl .users .get (1 )
608
602
with HTTMock (resp_get_user_status ):
609
603
status = user .status .get ()
610
- self .assertEqual ( type ( status ) , UserStatus )
604
+ self .assertIsInstance ( status , UserStatus )
611
605
self .assertEqual (status .message , "test" )
612
606
self .assertEqual (status .emoji , "thumbsup" )
613
607
@@ -636,7 +630,7 @@ def resp_mark_as_done(url, request):
636
630
637
631
with HTTMock (resp_get_todo ):
638
632
todo = self .gl .todos .list ()[0 ]
639
- self .assertEqual ( type ( todo ) , Todo )
633
+ self .assertIsInstance ( todo , Todo )
640
634
self .assertEqual (todo .id , 102 )
641
635
self .assertEqual (todo .target_type , "MergeRequest" )
642
636
self .assertEqual (todo .target ["assignee" ]["username" ], "root" )
@@ -683,10 +677,10 @@ def resp_update_submodule(url, request):
683
677
"committer_name": "Author",
684
678
"committer_email": "author@example.com",
685
679
"created_at": "2018-09-20T09:26:24.000-07:00",
686
- "message": "Message",
687
- "parent_ids": [ "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" ],
680
+ "message": "Message",
681
+ "parent_ids": [ "ae1d9fb46aa2b07ee9836d49862ec4e2c46fbbba" ],
688
682
"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",
690
684
"status": null}"""
691
685
content = content .encode ("utf-8" )
692
686
return response (200 , content , headers , None , 5 , request )
@@ -724,5 +718,5 @@ class MyGitlab(gitlab.Gitlab):
724
718
725
719
config_path = self ._default_config ()
726
720
gl = MyGitlab .from_config ("one" , [config_path ])
727
- self .assertEqual ( type ( gl ). __name__ , " MyGitlab" )
721
+ self .assertIsInstance ( gl , MyGitlab )
728
722
os .unlink (config_path )
0 commit comments