@@ -99,11 +99,9 @@ def _process_archs(arch):
9999 for a in arch .split (";" ):
100100 if '' == a :
101101 continue
102- assert a in [
103- "GPU" ,
104- "ROCM" ,
105- "XPU" ,
106- ], f"""Supported arch options are "GPU", "ROCM", and "XPU", but the options is { a } """
102+ assert a in ["GPU" , "ROCM" , "XPU" ], (
103+ f"""Supported arch options are "GPU", "ROCM", and "XPU", but the options is { a } """
104+ )
107105 archs += "WITH_" + a .upper () + " OR "
108106 arch = "(" + archs [:- 4 ] + ")"
109107 else :
@@ -127,11 +125,9 @@ def _process_os(os_):
127125 if len (os_ ) > 0 :
128126 os_ = os_ .upper ()
129127 for p in os_ .split (';' ):
130- assert p in [
131- "WIN32" ,
132- "APPLE" ,
133- "LINUX" ,
134- ], f"""Supported os options are 'WIN32', 'APPLE' and 'LINUX', but the options is { p } """
128+ assert p in ["WIN32" , "APPLE" , "LINUX" ], (
129+ f"""Supported os options are 'WIN32', 'APPLE' and 'LINUX', but the options is { p } """
130+ )
135131 os_ = os_ .replace (";" , " OR " )
136132 os_ = "(" + os_ + ")"
137133 else :
@@ -146,7 +142,9 @@ def _process_run_serial(run_serial):
146142 "1" ,
147143 "0" ,
148144 "" ,
149- ], f"""the value of run_serial must be one of 0, 1 or empty. But this value is { rs } """
145+ ], (
146+ f"""the value of run_serial must be one of 0, 1 or empty. But this value is { rs } """
147+ )
150148 if rs == "" :
151149 return ""
152150 return rs
@@ -175,9 +173,9 @@ def _process_name(name, curdir):
175173 )
176174 filepath_prefix = os .path .join (curdir , name )
177175 suffix = [".py" , ".sh" ]
178- assert _file_with_extension (
179- filepath_prefix , suffix
180- ), f""" Please ensure the test file with the prefix ' { filepath_prefix } ' and one of the suffix { suffix } exists, because you specified a unittest named ' { name } '"""
176+ assert _file_with_extension (filepath_prefix , suffix ), (
177+ f""" Please ensure the test file with the prefix ' { filepath_prefix } ' and one of the suffix { suffix } exists, because you specified a unittest named ' { name } '"""
178+ )
181179
182180 return name
183181
@@ -238,7 +236,9 @@ def process_dist_port_num(self, port_num):
238236 re .compile ("^[0-9]+$" ).search (port_num )
239237 and int (port_num ) > 0
240238 or port_num .strip () == ""
241- ), f"""port_num must be format as a positive integer or empty, but this port_num is '{ port_num } '"""
239+ ), (
240+ f"""port_num must be format as a positive integer or empty, but this port_num is '{ port_num } '"""
241+ )
242242 port_num = port_num .strip ()
243243 if len (port_num ) == 0 :
244244 return 0
@@ -272,7 +272,9 @@ def _init_dist_ut_ports_from_cmakefile(self, cmake_file_name):
272272
273273 # match right tests name format, the name must start with 'test_' followed by at least one char of
274274 # '0-9'. 'a-z'. 'A-Z' or '_'
275- assert re .compile ("^test_[0-9a-zA-Z_]+" ).search (
275+ assert re .compile (
276+ "^test_[0-9a-zA-Z_]+"
277+ ).search (
276278 name
277279 ), f'''we found a test for initial the latest dist_port but the test name '{ name } ' seems to be wrong
278280 at line { k - 1 } , in file { cmake_file_name }
@@ -349,9 +351,9 @@ def parse_assigned_dist_ut_ports(self, current_work_dir, depth=0):
349351 if name == self .last_test_name :
350352 found = True
351353 break
352- assert (
353- found
354- ), f"no such test named ' { self . last_test_name } ' in file ' { self . last_test_cmake_file } '"
354+ assert found , (
355+ f"no such test named ' { self . last_test_name } ' in file ' { self . last_test_cmake_file } '"
356+ )
355357 if launcher [- 2 :] == ".sh" :
356358 self .process_dist_port_num (num_port )
357359
@@ -485,9 +487,9 @@ def _parse_line(self, line, curdir):
485487 try :
486488 run_type = _process_run_type (run_type )
487489 except Exception as e :
488- assert (
489- run_type . strip () == " "
490- ), f" { e } \n If use test_runner.py, the run_type can be ''"
490+ assert run_type . strip () == "" , (
491+ f" { e } \n If use test_runner.py, the run_type can be '' "
492+ )
491493 cmd += f'''if({ archs } AND { os_ } )
492494 py_test_modules(
493495 { name }
@@ -580,7 +582,9 @@ def _gen_cmakelists(self, current_work_dir, depth=0):
580582 assert (
581583 f"{ current_work_dir } /CMakeLists.txt"
582584 not in self .modified_or_created_files
583- ), f"the file { current_work_dir } /CMakeLists.txt are modified twice, which may cause some error"
585+ ), (
586+ f"the file { current_work_dir } /CMakeLists.txt are modified twice, which may cause some error"
587+ )
584588 self .modified_or_created_files .append (
585589 f"{ current_work_dir } /CMakeLists.txt"
586590 )
@@ -630,15 +634,15 @@ def _gen_cmakelists(self, current_work_dir, depth=0):
630634 )
631635 args = parser .parse_args ()
632636
633- assert not (
634- len ( args . files ) == 0 and len ( args . dirpaths ) == 0
635- ), "You must provide at least one file or dirpath"
637+ assert not (len ( args . files ) == 0 and len ( args . dirpaths ) == 0 ), (
638+ "You must provide at least one file or dirpath"
639+ )
636640 current_work_dirs = []
637641 if len (args .files ) >= 1 :
638642 for p in args .files :
639- assert (
640- os . path . basename ( p ) == " testslist.csv"
641- ), "you must input file named testslist.csv"
643+ assert os . path . basename ( p ) == "testslist.csv" , (
644+ "you must input file named testslist.csv"
645+ )
642646 current_work_dirs = current_work_dirs + [
643647 os .path .dirname (file ) for file in args .files
644648 ]
0 commit comments