Python 如何显示在使用py.test时跳过某些测试的原因?
我正在使用Python 如何显示在使用py.test时跳过某些测试的原因?,python,unit-testing,pytest,Python,Unit Testing,Pytest,我正在使用unittest中的skipIf()跳过特定条件下的测试 @unittest.skipIf(condition), "this is why I skipped them!") 如何告诉py.test显示跳过条件 我知道,对于unittest,我需要启用详细模式(-v),但添加到py.test的相同参数增加详细度,但仍然不会显示跳过原因。运行py.test时,可以通过-rsx报告跳过的测试 从py.test--help: -r chars show extra
unittest
中的skipIf()
跳过特定条件下的测试
@unittest.skipIf(condition), "this is why I skipped them!")
如何告诉py.test
显示跳过条件
我知道,对于unittest,我需要启用详细模式(
-v
),但添加到py.test的相同参数增加详细度,但仍然不会显示跳过原因。运行py.test时,可以通过-rsx
报告跳过的测试
从py.test--help
:
-r chars show extra test summary info as specified by chars
(f)ailed, (E)error, (s)skipped, (x)failed, (X)passed.
另请参阅有关跳过的文档的这一部分:简短回答:
pytest -rs
这将显示跳过测试的额外信息
详细答案:
pytest -rs
为了补充@ToddWilson的答案,添加了以下字符:p
和p
(),a
()和a
()。默认情况下,不会显示有关跳过和失败测试的详细信息,以避免输出混乱。您可以将标志与以下字符一起使用:
- (
)故障f
- (
)错误E
- (
)kippeds
- (
)失败x
- (
)已通过X
- (
)已批准p
- (
)与输出一致P
- (
)除通过(p/p)外,其余均为lla
- (
)llA
fE