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

后端 未结 6 857
陌清茗
陌清茗 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:13

    Run pytest with -rf to get it to print a list of failed tests at the end.

    From py.test --help:

      -r chars              show extra test summary info as specified by chars
                            (f)ailed, (E)error, (s)skipped, (x)failed, (X)passed,
                            (p)passed, (P)passed with output, (a)all except pP.
                            Warnings are displayed at all times except when
                            --disable-warnings is set
    

    Here's what you get:

    $ py.test -rf
    ================= test session starts =================
    platform darwin -- Python 3.7.2, pytest-4.3.1, py-1.6.0, pluggy-0.7.1
    [...]
    =============== short test summary info ===============
    FAILED test_foo.py::test_foo_is_flar
    FAILED test_spam.py::test_spam_is_mostly_pork
    FAILED test_eggs.py::test_eggs_are_also_spam
    === 3 failed, 222 passed, 8 warnings in 12.52 seconds ==
    

提交回复
热议问题