ddt-数据驱动

匿名 (未验证) 提交于 2019-12-03 00:38:01
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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!