11import argparse
2+ import importlib
23import os
34import re
45import time
56import unicourt
67from unicourt .sdk .Authentication import Authentication
78
8-
99class TestBase :
1010 def __init__ (self ) -> None :
1111 self .parser = argparse .ArgumentParser ()
@@ -19,36 +19,33 @@ def __init__(self) -> None:
1919
2020 def run (self ):
2121 args = self .parser .parse_args ()
22- for module_name in [re .sub ("\.py" , "" , module )
23- for module in os .listdir (os .path .dirname (os .path .abspath (__file__ ))) if module .startswith ("test" ) and module .endswith ("py" )]:
22+ # getting the list of test file and re-order authentication test file at end to run.
23+ module_list = [re .sub ("\.py" , "" , module ) for module in os .listdir () if module .startswith ("test" ) and module .endswith ("py" )]
24+ index = module_list .index ('test_authentication_api' )
25+ module_list [index ], module_list [- 1 ] = module_list [- 1 ], module_list [index ]
26+ for module_name in module_list :
2427 module = __import__ (module_name )
25- class_name = [class_name for class_name in dir (
26- module ) if class_name .startswith ('Test' )][0 ]
27- if class_name == 'TestAuthentication' :
28- continue
28+ class_name = [class_name for class_name in dir (module ) if class_name .startswith ('Test' )][0 ]
2929 if args .exclude :
3030 if class_name in args .exclude .split ("," ):
3131 continue
3232 if args .include :
3333 if class_name not in args .include .split ("," ):
3434 continue
35+ print ("########### Testing" , class_name , "###########\n " )
3536 instance_obj = getattr (module , class_name )
36-
37- method_list = [meth for meth in dir (
38- instance_obj ) if meth .startswith ('test' ) is True ]
37+ method_list = [meth for meth in dir (instance_obj ) if meth .startswith ('test' ) is True ]
3938 for method_name in method_list :
4039 if hasattr (instance_obj , method_name ) and callable (function := getattr (instance_obj , method_name )):
4140 try :
4241 _ , status_code = function ()
43- print (method_name , status_code )
44- time .sleep (1 )
42+ print ("Method:" , method_name , " \n Status Code:" , status_code , " \n " )
43+ time .sleep (5 )
4544 except Exception as e :
46- Authentication .invalidate_token ()
47- raise Exception (e )
48-
45+ print ("Method:" , method_name , "\n Error" , e )
4946
5047def main ():
51- print ("############ Starting Test for SDK ############ " )
48+ print ("########### Starting Test for SDK ###########\n " )
5249 TestBase ().run ()
5350
5451
0 commit comments