pytest: How to get a list of all failed tests at the end of the session? (and while using xdist)

后端 未结 6 841
陌清茗
陌清茗 2021-02-18 17:03

I would like to have a list of all the tests that have failed to be used at the end of session.

Pytest lets you define a hook pyt

6条回答
  •  感动是毒
    2021-02-18 17:32

    --result-log is deprecated. You can instead use -v to output the test case names as they run. If you pipe that into a file, you can query it. So if you're running your tests from a script you can do something like:

    pytest -v | tee log.txt
    grep -E '::.*(FAILURE|ERROR)' log.txt
    

提交回复
热议问题