py.test xdist捕获每个进程的所有输出

时间:2015-10-23 17:33:55

标签: python python-2.7 pytest

我想使用pytest-xdist进行测试。我在3个进程中运行测试,但我的测试(和拆解)有stderr输出并想要捕获它。如果我使用:

def pytest_runtest_makereport(item, call):
    captured_stderr = item.outerr[1]
    if captured_stderr:
        with open("captured_" + str(os.getpid()), "a") as f:
            f.write(captured_stderr)

然后在captured_ *文件中有一个输出,但我希望它也有pytest诊断消息(因为我想稍后了解这个输出属于哪个测试),例如[gw0] PASSED file:line test_something。如何将控制台输出保存到文件,但每个进程将其拆分?

0 个答案:

没有答案
相关问题