使用 Coverage.py 和 Pytest 的测试用例代码覆盖率

问题描述

我正在尝试从每个 Pytest 测试用例中获取执行的代码 - 为了制作调试器 - 现在可以在 Coverage 模块 apis 中使用以下代码:

cov.start()
assert nrm.mySqrt(x) == 3 // this is a test case using Pytest
cov.stop()
cov.json_report()
cov.erase()// after this line i repeat the steps top

但它不实用,所以如果我使用 coverage run - m pytest fileName 命令它不会给我每个案例的报告,我试图使用插件来应用一些特殊情况,如果执行的行包括断言我想获得 JSON 报告并擦除数据,我能做到吗?或者我应该尝试找到一种方法来为每个测试用例植入上面的代码?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...