【发布时间】:2014-11-10 06:08:30
【问题描述】:
我能够设置鼻子测试以使用@attr 标记运行。我现在很想知道我是否可以附加到测试名称的末尾,@attr 标记?我们要做的是添加一个标签,如果我们的测试遇到问题并且我们为它写了一个缺陷,然后我们会将缺陷编号作为@attr 标签。然后,当我们运行时,我们可以轻松识别哪些测试存在针对它们的公开缺陷。
只是想知道这是否可能,以及去哪里查看如何设置?
编辑结果运行结果:
测试结果:
所以我有点知道发生了什么,如果我在班级级别有@fancyattr(),它会捡起它并更改班级的名称。当我将@fancyattr() 放在测试级别时,它不会更改测试的名称,这是我需要做的。
例如 - 更改类的名称:
@dms_attr('DMSTEST')
@attr('smoke_login', 'smoketest', priority=1)
class TestLogins(BaseSmoke):
"""
Just logs into the system and then logs off
"""
def setUp(self):
BaseSmoke.setUp(self)
def test_login(self):
print u"I can login -- taking a nap now"
sleep(5)
print u"Getting off now"
def tearDown(self):
BaseSmoke.tearDown(self)
这是我需要的,但它不起作用:
@attr('smoke_login', 'smoketest', priority=1)
class TestLogins(BaseSmoke):
"""
Just logs into the system and then logs off
"""
def setUp(self):
BaseSmoke.setUp(self)
@dms_attr('DMSTEST')
def test_login(self):
print u"I can login -- taking a nap now"
sleep(5)
print u"Getting off now"
def tearDown(self):
BaseSmoke.tearDown(self)
更新了我在__doc__看到的截图:
【问题讨论】:
-
更具体地说,您要修改带有属性的测试名称吗? IE。
@attr('slow')把func_test变成func_test_slow? -
@Oleksiy 是的,就是这样。
标签: python unit-testing python-2.7 nosetests