如何显示为什么在使用 py.test 时跳过了某些测试? [英] How to I display why some tests where skipped while using py.test?
问题描述
我正在使用 unittest
中的 skipIf()
在某些条件下跳过测试.
I am using skipIf()
from unittest
for skipping tests in certain conditions.
@unittest.skipIf(condition), "this is why I skipped them!")
如何告诉 py.test
显示跳过条件?
How do I tell py.test
to display skipping conditions?
我知道对于 unittest 我需要启用详细模式 (-v
) 但添加到 py.test 的相同参数增加了详细程度,但仍然不显示跳过原因.
I know that for unittest I need to enable the verbose mode (-v
) but the same parameter added to py.test increase the verbosity by still does not display the skip reasons.
推荐答案
运行 py.test 时,可以通过 -rsx
报告跳过的测试.
When you run py.test, you can pass -rsx
to report skipped tests.
来自 py.test --help
:
-r chars show extra test summary info as specified by chars
(f)ailed, (E)error, (s)skipped, (x)failed, (X)passed.
另请参阅有关跳过的文档的这一部分:http://doc.pytest.org/en/latest/skiping.html
Also see this part of the documentation about skipping: http://doc.pytest.org/en/latest/skipping.html
这篇关于如何显示为什么在使用 py.test 时跳过了某些测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!