xlrd操作excel # -*- coding: utf-8 -*- # @Time : 2020/2/12 9:14 # @File : do_excel_xlrd_11.py # @Author: Hero Liu import xlrd # 打开工作簿 work_book = xlrd.open_workbook("../data/test_data.xlsx") # 通过指定索引获取sheet表,索引从0开始:也可以通过指定表名来获取 # table = work_book.…
最最重要,处理case依赖.字段依赖 # -*- coding: utf-8 -*- # @Time : 2020/2/13 21:14 # @File : data_depend_17.py # @Author: Hero Liu from day_20200208_mooc.tools.do_excel_openpyxl_14 import DoExcel from day_20200208_mooc.base.interface_request_class_5 import RunMain…
把读取json数据的函数封装成类 # -*- coding: utf-8 -*- # @Time : 2020/2/12 16:44 # @File : do_json_13.py # @Author: Hero Liu import json class DoJson: def __init__(self, file): self.data = self.get_json(file) # 读取json文件 def get_json(self, file): with open(file) as…
从excel中读取数据 # -*- coding: utf-8 -*- # @Time : 2020/2/12 17:23 # @File : do_excel_openpyxl_14.py # @Author: Hero Liu from openpyxl import load_workbook from day_20200208_mooc.tools.do_json_13 import DoJson import json class DoExcel: def get_data(self,…
执行测试用例 # -*- coding: utf-8 -*- # @Time : 2020/2/12 22:56 # @File : run_test_16.py # @Author: Hero Liu import sys sys.path.append("h:/python_lemon") import unittest from day_20200208_mooc.base.test_class_15 import TestRequest import HTMLTestRunne…
ddt.依赖测试.断言.测试数据写回 # -*- coding: utf-8 -*- # @Time : 2020/2/12 23:07 # @File : test_class_15.py # @Author: Hero Liu # 相当于案例中的runmethod.py import unittest from day_20200208_mooc.base.interface_request_class_5 import RunMain from day_20200208_mooc.tool…
给多个人发邮件时,可以传入邮箱列表 把多个收件人用分号隔开 # -*- coding: utf-8 -*-# @Time : 2020/2/15 17:02# @File : send_mail_19.py# @Author: Hero Liuimport smtplibimport timefrom email.mime.multipart import MIMEMultipartfrom email.mime.text import MIMETextfrom email.mime.appli…
这里是把传入的请求数据作为响应值返回 # -*- coding: utf-8 -*- # @Time : 2020/2/15 9:47 # @File : do_mock_18.py # @Author: Hero Liu # 接口不可用,模拟返回响应数据 import mock def mock_test(mock_method, url, method, request_data, response_data, header=None): mock_method = mock.Mock(re…
封装mock后,在单元测试中调用 # -*- coding: utf-8 -*- # @Time : 2020/2/11 8:35 # @File : test_class_10.py.py # @Author: Hero Liu # 单元测试框架 import unittest from day_20200208_mooc.base.interface_request_class_5 import RunMain from day_20200208_mooc.base.mock_demo_9…
封装mock # -*- coding: utf-8 -*- # @Time : 2020/2/12 8:51 # @File : mock_demo_9.py # @Author: Hero Liu # 封装mock import mock def mock_test(mock_method, url, method, request_data, response_data): """ :param mock_method: 封装的请求函数 :param url: 请求UR…