import requests import unittest from parameterized import parameterized as pd def read_file(file_name): result = [] with open(file_name, encoding=‘utf-8‘) as fr: for line in fr: line = line.strip() if line: result.append(line.split(‘,‘)) return result def read_excel(): pass def get_data_from_mysql(sql): pass class InterFaceCase(unittest.TestCase): @pd.expand([ [‘http://api.nnzhp.cn/api/user/stu_info‘, ‘stu_name=矿泉水‘, ‘矿泉水‘], [‘http://api.nnzhp.cn/api/user/stu_info‘, ‘stu_name=小黑‘, ‘小黑‘], [‘http://api.nnzhp.cn/api/user/stu_info‘, ‘stu_name=‘, ‘小黑‘], ]) #@pd.expand(read_file(‘login.txt‘)) def testlogin(self, url, data, check): # username=abc&password=1234 url = url + ‘?‘ + data result = requests.get(url).text #判断check是否包含在result中
self.assertIn(check, result) # 1、查找测试用例 unittest.main()
原文:https://www.cnblogs.com/skyxiuli/p/11012840.html