首页 > 其他 > 详细

ddt-数据驱动

时间:2018-06-28 20:15:48      阅读:147      评论:0      收藏:0      [点我收藏+]
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)


ddt-数据驱动

原文:https://www.cnblogs.com/1376402226-yuyu/p/9240443.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!