python - 在 pytest-ing 时禁用每个测试“点”
问题描述
我有大约 10^5 个测试的参数化测试套件。因此,我正在调试引发的错误,即使用-x
标志。像这样:
pytest tests.py -x
这里的问题是这个命令使终端与.
每个测试相对应。这是不希望的(因为我没有任何 xfaild 或其他东西 - 仅通过与否;并且由于测试的数量):
............................................................................................................................................................................................................ [ 5%]
............................................................................................................................................................................................................ [ 11%]
............................................................................................................................................................................................................ [ 17%]
如何禁用这个“点”并只留下进度条?也许一些插件?试过了-q
,但点还在打印。
解决方案
你可以pytest_report_teststatus()
在你的conftest.py
. 它返回一个元组结果类别、短字母和详细词。
def pytest_report_teststatus(report, config):
if report.passed and report.when == "call":
return report.outcome, "", report.outcome.upper()
每次测试都会调用钩子 3 次,report.when
设置为"setup"
,"call"
或"teardown"
。"call"
如果测试在阶段中通过,上面的回调将 shortletter 设置为空字符串。
推荐阅读
- c# - ASP.NET 会话适用于所有浏览器,但不适用于最新的 Firefox
- docker - Kafka 容器在一段时间后停止,客户端会话超时
- php - 在 laravel 中连接 php
- docker - 使用 rules_docker 的 container_image 规则创建的镜像中文件的时间戳都设置为零
- angular - 当我在 amcharts 中选择一个部分时,如何获得准确的范围值?
- benchmarkdotnet - 使用 BenchmarkDotNet 在基准之间保留数据
- c - 我需要创建一个十进制到二进制程序,它可以接收多达 100,000,000 的输入并输出整个答案而不显示垃圾
- go - Go 命令获取关键字或保留字列表?
- google-bigquery - BigQuery 删除重复项保持最后
- java - 在 Spring Boot 中查询自动生成的表