What numbers can you pass as verbosity in running Python Unit Test Suites?

*爱你&永不变心* 提交于 2019-12-20 08:48:11

问题


The Python unittest framework has a concept of verbosity that I can't seem to find defined anywhere. For instance, I'm running test cases like this (like in the documentation):

suite = unittest.TestLoader().loadTestsFromTestCase(MyAwesomeTest)
unittest.TextTestRunner(verbosity=2).run(suite)

The only number I've ever seen passed as verbosity is 2. What is this magic number, what does it mean, what what else can I pass?


回答1:


You only have 3 different levels:

  • 0 (quiet): you just get the total numbers of tests executed and the global result
  • 1 (default): you get the same plus a dot for every successful test or a F for every failure
  • 2 (verbose): you get the help string of every test and the result

You can use command line args rather than the verbosity argument: --quiet and --verbose which would do something similar to passing 0 or 2 to the runner.



来源:https://stackoverflow.com/questions/1322575/what-numbers-can-you-pass-as-verbosity-in-running-python-unit-test-suites

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