一种在setup()中输出pyunit测试名称的方法 [英] A way to output pyunit test name in setup()
本文介绍了一种在setup()中输出pyunit测试名称的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
python 中有没有办法让 pyunit 测试输出它当前正在运行的测试.示例:
Is there a way in python for a pyunit test to output the test it's currently running. Example:
def setUp(self):
log.debug("Test %s Started" % (testname))
def test_example(self):
#do stuff
def test_example2(self):
#do other stuff
def tearDown(self):
log.debug("Test %s Finished" % (testname))
推荐答案
您可以使用 self._testMethodName
.这是继承自unittest.TestCase
代码> 父类.
You can use self._testMethodName
. This is inherited from the unittest.TestCase
parent class.
def setUp():
print "In method", self._testMethodName
这篇关于一种在setup()中输出pyunit测试名称的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文