pytest复习笔记01--print坑

在写pytest测试用例脚本时,使用print函数来进行打印调试,发现不会打印print语句,原因为pytest

根据pytest文档,pytest的第3版可以在测试中临时禁用捕获:

def test_disabling_capturing(capsys):
    print('this output is captured')
    with capsys.disabled():
        print('output not captured, going directly to sys.stdout')
    print('this output is also captured')
如果想实现标准输出,则需要加上 -s来执行测试脚本
pytest - s test_*.py
上一篇:原创pytest辅助工具tep0.9.1版本恢复项目初始化文件


下一篇:pytest学习03--pycharm运行pytest