On , I learnt ...

How to use xmllint to extract the failing test filenames from a JUnit-XML file

Pytest will generate a JUnit-XML result report when run with the --junitxml option.

To extract the names the files containing failing tests, this xmllint command can be used:

xmllint --xpath '//testcase[.//failure]/@file' results.xml | \
    tr " " "\n" | awk 'BEGIN { FS="\"" } { print $2 }' | \
    sort | uniq

Here we:

This is a little convoluted. XMLLint doesn’t support using a string XPath function to print the attribute values of all matches (it only prints the first one) which is why we need to pipe out to standard Unix tools.