我有一些测试,如:
@attr('sanity', 'someothertag')
def test_this_important_feature(self):
"""Comment - Verify the very imporant feature
我想知道是否可以从测试中查看测试中的属性。或者(可能最好),有没有办法将每个测试的属性链接到Nose发现的每个测试?对于上面的例子,它类似于:
test_this_important_feature: ('sanity','someothertag')
我运行所有这些测试并使用nose.run(配置)捕获结果 - 结果是否能够拥有每个测试的属性?
答案 0 :(得分:0)
属性可直接作为函数的字典使用,即test_this_important_feature.__dict__
将具有所有属性。如果您不想对该函数的名称进行硬编码,请查看此答案中的get_attr_dict()。对于答案的第二部分,您还可以展开for fancy printout