繁体   English   中英

从 pytest 中的测试名称中隐藏 class

[英]Hiding class from the test name in pytest

我在模块中有一个测试类。 testclass 和 module 都或多或少具有相同的名称,我不希望在该模块中有第二个 class。

我的 pytest output 看起来像这样:

test_vlans.py::TestVlan::test_normal[delete_vlans] PASSED                              [  4%]
test_vlans.py::TestVlan::test_normal[alter_vlans] PASSED                               [  8%]
test_vlans.py::TestVlan::test_normal[add_vlans] PASSED                                 [ 13%]
test_vlans.py::TestVlan::test_idempotence[delete_vlans] PASSED                         [ 17%]
...

测试类:

class TestVlan(BasicTestScenario):
    target = "vlans"

我觉得TestVlan在这里是多余的。 如何从测试名称中排除 class 名称?

命名约定

如果测试定义为 class 上的方法,则 class 名称应以“Test”开头,如 TestExample 中所示。

由此,我会假设(a)你不必打电话给你的 class TestVlan但是(b)你应该Test开始,即使你不必这样做。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM