Pytest - 测试结果的自定义输出 [英] Pytest - custom output of test results

查看:94
本文介绍了Pytest - 测试结果的自定义输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想完全自定义测试结果输出.在 unittest 中,我可以通过 unittest.TextTestRunner 的例子来实现我自己的测试运行器.我如何在 pytest 中做同样的事情?

I want to completely custom tests results output. In unittest I can implement my own test runner by example of unittest.TextTestRunner. How can I do the same in pytest?

推荐答案

你需要使用 pytest 钩子:

py.test 调用钩子函数实现初始化、运行、测试执行和报告.

py.test calls hook functions to implement initialization, running, test execution and reporting.

另见:

  • py.test code snippets
  • pycon tutorial session (it also goes through using hooks)

这篇关于Pytest - 测试结果的自定义输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆