How to customize python unittest tests output?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 00:55:59

问题


I am working in the database domain. Few days back I started working on unit testing using python's most popular package i.e. unittest. I am totally new to python unittest. I want to test some database opreations like Add/update/delete with different database servers. I want the final test result as below

sample result
-------------------
==============
server 1: 20 passed 10 failed
server 2: 10 passed 20 failed
==============

and so on...

My current class structure is

Class DB_Test(uniittest.Testcase):
    def setUpClass(self):
         <generate predata(like create server, connect to server)>
    def runTest(self):
         for server in server_list:
               add_db(<server_data>,<db_data>)
    def tearDown(self):
         <clean the predata>

So, How to customise the code so that I can capture the test result serverwise? Now its showing default test result with ok & fail.

来源:https://stackoverflow.com/questions/39018204/how-to-customize-python-unittest-tests-output

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