github.com/tiagovtristao/plz@v13.4.0+incompatible/tools/please_pex/pytest.py (about) 1 import os 2 3 4 def run_tests(args): 5 """Runs tests using pytest, returns the number of failures.""" 6 # N.B. import must be deferred until we have set up import paths. 7 from pytest import main 8 args = args or [] 9 10 # Added this so the original filter functionality by name does not change 11 if args: 12 filtered_tests = '' 13 14 for i in args[:]: 15 if not i.startswith('-'): 16 filtered_tests += i + ' ' 17 args.remove(i) 18 19 if filtered_tests: 20 try: 21 args.remove('-k') 22 except ValueError: 23 pass 24 args += ['-k', filtered_tests.strip()] 25 26 args += ['--junitxml', 'test.results'] + TEST_NAMES 27 28 if os.environ.get('DEBUG'): 29 args.append('--pdb') 30 return main(args)