paramunittest
1、通过pip的方法进行安装: pip install paramunittest
2、官方文档:https://pypi.python.org/pypi/ParamUnittest/
3、源码地址:https://github.com/rik0/ParamUnittest
源码:
数据以元组的形式进行存放。通过parametrized方法进行添加参数
# coding:utf-8 import unittest import paramunittest # 参数位置 @paramunittest.parametrized( ( "wanwan", "mama"), ("doudou", "baobao"), ) class TestDemo(unittest.TestCase): def setParameters(self, name, test): self.user = name self.pwd = test def testcase(self): print("用户名:%s" % self.user) print("密码:%s" % self.pwd) if __name__ == "__main__": unittest.main(verbosity=2)
也可以通过字典的形式
注意:字典形式的参数需要下面我们要进行一一对应。
# coding:utf-8 import unittest import paramunittest # 参数位置 @paramunittest.parametrized( {"user":'wanwan',"pwd":"test"}, {"user":'doudou',"pwd":"test1"}, ) class TestDemo(unittest.TestCase): def setParameters(self, user, pwd): self.user = user self.pwd = pwd def testcase(self): print("用户名:%s" % self.user) print("密码:%s" % self.pwd) if __name__ == "__main__": unittest.main(verbosity=2)标签:__,self,---,pwd,user,paramunittest,unittests,unittest From: https://www.cnblogs.com/yi-ying/p/17093879.html