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 @   多测师_树哥  阅读(166)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)
点击右上角即可分享
微信分享提示