@ddt数据驱动+unitest框架

import csv
import unittest
from time import sleep

from ddt import ddt, data, unpack
from selenium import webdriver


def getCsvData():
# 读取CSV文件
value_rows = []
with open(‘C:\\Users\\zhouhai-1000\\Desktop\\ycsj.csv‘, "r", encoding=‘utf-8‘) as f:
f_csv = csv.reader(f)
next(f_csv)
for r in f_csv:
value_rows.append(r)
return value_rows

@ddt
# 数据驱动
class MyTestCase(unittest.TestCase):

def setUp(self):
print("开始")

@data(*getCsvData())
# 测试数据

@unpack
# 解包
def test_something(self, value):
print(value)

def tearDown(self):
print("结束")

if __name__ == ‘__main__‘:
unittest.main()

@ddt数据驱动+unitest框架

上一篇:整除分块


下一篇:django-apscheduler 实现定时任务详解