如何从python中的测试方法中提取测试方法名称

2024-04-23 22:47:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我把各种python unitttest方法打包成一个TestSuite,其中一个特定的测试方法看起来像

<input.MyTest testMethod=test_simple>

看起来这是一个类(这个东西的类型是input.MyTest),但是有一个附加属性(?)试验方法。在

如何从属性testMethod(或其他任何属性)中提取名称test_simple?在

测试代码(我的测试.py)在

^{pr2}$

套房代码

from input import MyTest
suite = test.TestSuite()
suite.addTest(MyTest("test_simple"))
print suite._tests[0]

Tags: 方法pytest名称类型input属性simple
1条回答
网友
1楼 · 发布于 2024-04-23 22:47:34

快速阅读文档后,您可能想从^{}开始

id()

Return a string identifying the specific test case. This is usually the full name of the test method, including the module and class name.

相关问题 更多 >