Assuming the test names are unique, you have to remove the test file's name:
cat foo.txt | cut -d : -f 3 foo.txt > FAILED_TESTS.txt
As others pointed out use -k
, but you have to pass the file's content (i.e., list of test names) as a single string:
pytest -k "`cat FAILED_TESTS.txt | "$(awk '$1=$1' RS= OFS=' or ' `" FAILED_TESTS.txt)"
awk
will replace the new lines with a delimiter or
so that the test names are joined in a format that pytest expects.