@@ -510,14 +510,22 @@ def main():
510510
511511 # Remove the test cases that the user has explicitly asked to exclude.
512512 if args .exclude :
513- exclude_tests = [test .split ('.py' )[0 ] for test in args .exclude .split (',' )]
513+ def print_warning_missing_test (test_name ):
514+ print ("{}WARNING!{} Test '{}' not found in current test list." .format (BOLD [1 ], BOLD [0 ], test_name ))
515+ exclude_tests = [test .strip () for test in args .exclude .split ("," )]
514516 for exclude_test in exclude_tests :
515- # Remove <test_name>.py and <test_name>.py --arg from the test list
516- exclude_list = [test for test in test_list if test .split ('.py' )[0 ] == exclude_test ]
517- for exclude_item in exclude_list :
518- test_list .remove (exclude_item )
519- if not exclude_list :
520- print ("{}WARNING!{} Test '{}' not found in current test list." .format (BOLD [1 ], BOLD [0 ], exclude_test ))
517+ if exclude_test .endswith ('.py' ):
518+ # Remove <test_name>.py and <test_name>.py --arg from the test list
519+ exclude_list = [test for test in test_list if test .split ('.py' )[0 ] == exclude_test .split ('.py' )[0 ]]
520+ if not exclude_list :
521+ print_warning_missing_test (exclude_test )
522+ for exclude_item in exclude_list :
523+ test_list .remove (exclude_item )
524+ else :
525+ try :
526+ test_list .remove (exclude_test )
527+ except ValueError :
528+ print_warning_missing_test (exclude_test )
521529
522530 if args .filter :
523531 test_list = list (filter (re .compile (args .filter ).search , test_list ))
0 commit comments