[英]Hiding class from the test name in pytest
I have a testclass inside a module.我在模块中有一个测试类。 Both testclass and module have more or less the same name and I don't expect to have the second class in this module.
testclass 和 module 都或多或少具有相同的名称,我不希望在该模块中有第二个 class。
My pytest output looks like this:我的 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%]
...
Testclass:测试类:
class TestVlan(BasicTestScenario):
target = "vlans"
I feel like TestVlan
is redundant here.我觉得
TestVlan
在这里是多余的。 How to exclude class name from the test name?如何从测试名称中排除 class 名称?
From the naming conventions :从命名约定:
If tests are defined as methods on a class, the class name should start with “Test”, as in TestExample.
如果测试定义为 class 上的方法,则 class 名称应以“Test”开头,如 TestExample 中所示。
From that, I would assume (a) you don't have to call your class TestVlan
but (b) you should start with Test
, even though you don't have to.由此,我会假设(a)你不必打电话给你的 class
TestVlan
但是(b)你应该从Test
开始,即使你不必这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.