@@ -151,12 +151,17 @@ def run_unittests(unittests):
151
151
return [res .get ()[1 ] for res in results ]
152
152
153
153
154
- def get_unittests (base_tests_path , limit = None , sort = True ):
154
+ def get_unittests (base_tests_path , limit = None , sort = True , skip_tests = None ):
155
155
def _sorter (iterable ):
156
156
return sorted (iterable ) if sort else iterable
157
157
unittests = [os .path .join (base_tests_path , name )
158
158
for name in _sorter (os .listdir (base_tests_path ))
159
159
if name .startswith ("test_" )]
160
+ if skip_tests :
161
+ log ("[INFO] skipping unittests: {}" , skip_tests )
162
+ cnt = len (unittests )
163
+ unittests = [t for t in unittests if t not in skip_tests ]
164
+ log ("[INFO] running {} of {} unittests" , len (unittests ), cnt )
160
165
return unittests [:limit ] if limit else unittests
161
166
162
167
@@ -624,6 +629,8 @@ def main(prog, args):
624
629
parser .add_argument ("-l" , "--limit" , help = "Limit the number of unittests to run." , default = None , type = int )
625
630
parser .add_argument ("-t" , "--tests_path" , help = "Unittests path." , default = PATH_UNITTESTS )
626
631
parser .add_argument ("-o" , "--only_tests" , help = "Run only these unittests (comma sep values)." , default = None )
632
+ parser .add_argument ("-s" , "--skip_tests" , help = "Run all unittests except (comma sep values)."
633
+ "the only_tets option takes precedence" , default = None )
627
634
parser .add_argument ("path" , help = "Path to store the csv output and logs to." , nargs = '?' , default = None )
628
635
629
636
global flags
@@ -638,14 +645,16 @@ def main(prog, args):
638
645
else :
639
646
log ("[INFO] results will not be saved remotely" )
640
647
648
+ def _fmt (t ):
649
+ t = t .strip ()
650
+ return os .path .join (flags .tests_path , t if t .endswith (".py" ) else t + ".py" )
651
+
641
652
if flags .only_tests :
642
- def _fmt (t ):
643
- t = t .strip ()
644
- return os .path .join (flags .tests_path , t if t .endswith (".py" ) else t + ".py" )
645
653
only_tests = set ([_fmt (test ) for test in flags .only_tests .split ("," )])
646
654
unittests = [t for t in get_unittests (flags .tests_path ) if t in only_tests ]
647
655
else :
648
- unittests = get_unittests (flags .tests_path , limit = flags .limit )
656
+ skip_tests = set ([_fmt (test ) for test in flags .skip_tests .split ("," )]) if flags .skip_tests else None
657
+ unittests = get_unittests (flags .tests_path , limit = flags .limit , skip_tests = skip_tests )
649
658
650
659
results = run_unittests (unittests )
651
660
txt_report_path = file_name (TXT_RESULTS_NAME , current_date )
0 commit comments