ddt数据驱动最简单的应用二【多测师】

import ddt
import unittest
from HTMLTestRunner_cn import HTMLTestRunner
import os
test_data=[1,2,3]


def run(value):

    print(value)

def suites(testPath):
    discover = unittest.defaultTestLoader.discover(testPath, pattern='test_ddtapi.py', top_level_dir=None)
    return discover

def makeHtml(htmlPath,suite):
        with open(htmlPath, 'wb') as f:
            runner = HTMLTestRunner(stream=f, title="ddt report", description="测试报告:", verbosity=0,tester='多测师_王sir')
            runner.run(suite)
def main():

    testPath=os.getcwd()
    suite=suites(testPath)
    htmlPath=r'C:\Users\Administrator\lib\report\ddtTest.html'
    makeHtml(htmlPath,suite)

@ddt.ddt
class TestDebug(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        pass
    @classmethod
    def tearDownClass(cls):
        pass

    @ddt.data(*test_data)
    def test_run(self,value):
        run(value)

if __name__ == '__main__':
    main()

 

posted @ 2020-06-12 20:27  多测师_王sir  阅读(165)  评论(0编辑  收藏  举报