pytest capsys: checking output AND getting it reported?

前端 未结 3 2108
盖世英雄少女心
盖世英雄少女心 2021-02-13 03:04

Python 3.4.1, pytest 2.6.2.

When a test fails, pytest will routinely report what was printed to stdout by the test. For instance this code:

         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-13 03:53

    From the documentation the behavior seems correct: only after the test function (test_result_and_stdout) finishes the output streams will be restored, not after each readouterr call. I don't think that currently capsys supports also redirecting to the original streams besides capturing them, which seems to be what you want.

    I would suggest to create an issue in the official repository and see what people have to say.

提交回复
热议问题