这可能非常简单,但我在文档中找不到。当我pytest
在一个项目上运行时,我看到一堆用于单个测试的点和字母,例如
test.py .............g..................
字母“g”在这里是什么意思?格式记录在哪里?
这可能非常简单,但我在文档中找不到。当我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')
所以在这里我覆盖了从 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
您的输出中的含义,因为我不知道您正在使用什么 pytest 插件或您的项目中可能存在的任何覆盖行为。
也许尝试使用 -v 选项运行 pytest 以查看它是否为您提供更详细的输出来解释该状态的含义。