即使AssertionError也导出pytest结果

时间:2018-06-18 08:57:41

标签: python pytest logfile tox

您好我有一个tox文件,它在我的项目上运行pytest并导出测试结果,当所有这些都通过但是当其中一个失败,并且我得到一个AssertionError,我无法将我的日志保存在我的结果文件中。即使测试失败,您有任何想法或解决方案来保存日志吗?

1 个答案:

答案 0 :(得分:0)

使用tryexcept语句来处理异常

示例:

try:
     #put your pytest stuff here
except AssertionError:
    pass

如果一切顺利,您的日志应立即保存!