如何在python unittest中增加详细程度? [英] How to increase verbosity in python unittest?
问题描述
我有一个测试用例 class
像这样:
import unittest
/ pre>
import sys
class Test(unittest.TestCase):
def test_a(self):
pass
def test_b(self):
pass
#etc
如果__name__ ==__main__:
unittest.main(verbosity = 2)
这是使用PyDev的eclipse中的文件。我运行它作为单元测试。不知何故,verbosity选项不会触发。没有错误。我想念什么?
解决方案我发现答案是在 eclipse配置和不在源代码中。
打开首选项 - > PyDev - > PyUnit ,并调整测试运行器的参数领域。更改
- verbosity0
至- verbosity2
或任何您喜欢的数字。不幸的是,我不知道,你可以设置多高。
正如@Jace在评论中指出的,
- verbosity0
to- verbosity9
。I have a test case
class
like this one:import unittest import sys class Test(unittest.TestCase): def test_a(self): pass def test_b(self): pass # etc if __name__ == "__main__": unittest.main(verbosity=2)
This is a file in eclipse using PyDev. I run it as unittest. Somehow the verbosity option does not trigger. There are no errors. What do I miss?
解决方案I figured out, that the Answer is in the eclipse configuration and not in the source code.
Open Preferences -> PyDev -> PyUnit and adjust the Parameters for test runner field. change
--verbosity0
to--verbosity2
or whatever number you like.Unfortunately I don't know, how high you can set this.As @Jace pointed out in the comments the verbosity-levels range from
--verbosity0
to--verbosity9
.这篇关于如何在python unittest中增加详细程度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!