import unittest
from ddt import ddt,data,unpack
from src.utils.ReadExcel import ReadExcel
@ddt
class Testddt2(unittest.TestCase):
def setUp(self):
pass
'''
*的作用类似于将原始数据的最外层括号拿掉,例如我们的原始数据是:
[['123456', 111], ['111', 'aaa'], ['123458', 'aaa'], ['123459', 'aaa']]
加上*之后变成:
['123456', 111], ['111', 'aaa'], ['123458', 'aaa'], ['123459', 'aaa']
然后可使用@unpack读取值,参数两位,运行结果:
123456 111
111 aaa
123458 aaa
123459 aaa
'''
@data(*ReadExcel().get_data())
@unpack
def test_1(self, username, password, message):
print()
print(username, password, message)
'''
不加*,不拆包时运行结果:
[['123456', 111.0], ['111', 'aaa'], ['123458', 'aaa'], ['123459', 'aaa']]
'''
@data(ReadExcel().get_data())
def test_2(self, value):
print()
print("---test_2---")
print(value)
'''
不加*,使用@unpack时,运行结果:
['123456', 111.0] ['111', 'aaa'] ['123458', 'aaa'] ['123459', 'aaa']
'''
@data(ReadExcel().get_data())
@unpack
def test_3(self, value1, value2, value3, value4):
print()
print("---test_3---")
print(value1, value2, value3, value4)
|