How to increase verbosity in python unittest?

只谈情不闲聊 提交于 2019-12-12 10:49:35

问题


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?


回答1:


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.




回答2:


Set the verbosity=0 (or 1 up to 2 ) in the Parameters for test runner field of pyUnit windows preference in Eclipse.



来源:https://stackoverflow.com/questions/6429577/how-to-increase-verbosity-in-python-unittest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!