[英]What does the letter “g” mean for some tests in pytest's output?
这可能非常简单,但我在文档中找不到。 当我在一个项目上运行pytest
时,我看到一堆用于单个测试的点和字母,例如
test.py .............g..................
字母“g”在这里是什么意思? 格式记录在哪里?
带有g
的测试状态不是标准状态,您必须有一些 pytest 插件更改此行为或在您的 conftest.py 文件中编写自定义行为。 所以作为一个基本的例子。
计算.py
def add(a, b):
return a + b
test_calc.py
from calc import add
def test_add_success():
assert add(10, 5) == 15
def test_add_failure():
assert add(10, 5) == 20
def test_add_success_again():
assert add(10, 10) == 20
conftest.py
def pytest_report_teststatus(report):
if report.when == "call" and report.failed:
return (report.outcome, 'g', 'god it doesnt work')
所以在这里我将默认故障 output 从 f 覆盖到 g。 如果我用 --tb=no 运行它
collected 3 items
test_calc.py .g.
或使用 -v 选项
test_calc.py::test_add_success PASSED [ 33%]
test_calc.py::test_add_failure god it doesnt work [ 66%]
test_calc.py::test_add_success_again PASSED [100%]
因此您可以看到默认行为已更改。 不幸的是,由于无法访问您的所有源代码,因此无法说出g
在您的 output 中的含义,因为我不知道您正在使用什么 pytest 插件或您的项目中可能存在的任何覆盖行为。
也许尝试使用 -v 选项运行 pytest 以查看它是否为您提供更详细的 output 解释该状态的含义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.