import unittest
from ddt import ddt, data, unpack
@ddt
class FooTestCase(unittest.TestCase):
@data((3, 2), (4, 3), (5, 3))
@unpack
def test_tuples_extracted_into_arguments(self, first_value, second_value):
self.assertTrue(first_value > second_value)
@data([3, 2], [4, 3], [5, 3])
@unpack
def test_list_extracted_into_arguments(self, first_value, second_value):
self.assertTrue(first_value > second_value)
@unpack
@data({‘first‘: 1, ‘second‘: 3, ‘third‘: 2},
{‘first‘: 4, ‘second‘: 6, ‘third‘: 5})
def test_dicts_extracted_into_kwargs(self, first, second, third):
print(first, second, third)
self.assertTrue(first < third < second)
if __name__ == ‘__main__‘:
unittest.main(verbosity=2)
原文:https://www.cnblogs.com/1376402226-yuyu/p/9240443.html