【问题标题】:Export pytest results even when AssertionError即使 AssertionError 也导出 pytest 结果
【发布时间】:2018-06-26 20:25:15
【问题描述】:

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

【问题讨论】:

    标签: python pytest logfile tox


    【解决方案1】:

    使用tryexcept 语句处理异常

    例子:

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

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

    【讨论】:

      猜你喜欢
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-11
      • 2018-06-23
      • 1970-01-01
      • 2019-08-05
      相关资源
      最近更新 更多