七秒鱼记忆~
每天进步一点点!!!

随笔分类 -  接口自动化

接口自动化-->文件下载
摘要:url ='XXX' cookies ={"id":"123456"} res =requests.get(url,cookies=cookies) if res.status_code == 200: #写入文件 with open('F:\\script\\download\\test_05.z 阅读全文
posted @ 2021-06-28 17:56 fishing~ 阅读(97) 评论(0) 推荐(0)
接口自动化-->文件上传
摘要:接口请求: import requests #上传接口的参数 files = {"projectFile": ('sub_process.json', open("F:\\上传文件\\task_01.json", 'rb'), "application/json")} #参数说明: #project 阅读全文
posted @ 2021-06-28 17:20 fishing~ 阅读(323) 评论(0) 推荐(0)
接口自动化-->数据库操作
摘要:#mysql操作 #安装pymysql,pip install pymysql from pymysql.cursors import DictCursor import pymysql #1、建立连接 con =pymysql.connect(host='地址', user='用户名', pass 阅读全文
posted @ 2021-06-03 09:58 fishing~ 阅读(19) 评论(0) 推荐(0)
接口自动化-->配置文件
摘要:#配置文件 #1、python文件 # class ConfigFile: # name ="hhh" # age ="18" # print(ConfigFile.name) #2、yaml文件 #1、创建yaml格式文件 #2、安装yaml,pip pyyaml #3、导入 import yam 阅读全文
posted @ 2021-06-01 11:03 fishing~ 阅读(13) 评论(0) 推荐(0)
接口自动化-->日志处理
摘要:import logging #日志级别: """ 1、debug:调试信息 2、info:主体功能信息,流水 3、warning:警告 4、error:错误 5、critical:严重的,致命的 """ #级别定义 logging.error("这是一条错误信息") #日志收集器: #1、日志收集 阅读全文
posted @ 2021-06-01 11:01 fishing~ 阅读(20) 评论(0) 推荐(0)
接口自动化-->前后置条件&ddt
摘要:import os import ddt import unittest from test.test_api.excel_handler import ExcelHandler @ddt.ddt class TestCls(unittest.TestCase): dir_name = os.pat 阅读全文
posted @ 2021-06-01 11:00 fishing~ 阅读(20) 评论(0) 推荐(0)
接口自动化-->excel操作
摘要:import os import openpyxl data_path =os.path.dirname(os.path.abspath(__file__)) file_path =os.path.join(data_path,'data.xlsx') #工具:openpyxl、tablib、pan 阅读全文
posted @ 2021-06-01 10:57 fishing~ 阅读(20) 评论(0) 推荐(0)
接口自动化--收集运行用例
摘要:#收集测试用例 import os import time import unittest from ingestion_api.libs.HTMLTestRunnerNew import HTMLTestRunner from ingestion_api.config.setting import 阅读全文
posted @ 2021-04-30 17:26 fishing~ 阅读(14) 评论(0) 推荐(0)
接口自动化--unittest单元测试
摘要:#unittest单元测试 #模块名以test开头;类名以Test开头,测试类继承unittest.TestCase;方法以test开头 固定用法; #断言:assert,断言失败会报错,使用try...except捕获异常 #测试用例运行方式: #以python方式运行:python 模块名 #命 阅读全文
posted @ 2021-04-30 17:25 fishing~ 阅读(19) 评论(0) 推荐(0)
接口自动化--requests
摘要:#导入requests库 # 安装:pip install requests # 镜像源安装:-i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com import requests #访问接口地址 res =requests. 阅读全文
posted @ 2021-04-30 17:23 fishing~ 阅读(20) 评论(0) 推荐(0)
利用正则表达式处理动态参数
摘要:st ='{"id":"#id#","data":"#data#","message":"#message#"}' pattern =r'#(.*?)#' findall匹配全部 st =re.findall(pattern,st) 运行结果 ['id', 'data', 'message'] se 阅读全文
posted @ 2020-11-20 14:40 fishing~ 阅读(156) 评论(0) 推荐(0)
利用pandas读取excel数据操作
摘要:import pandas as pd import xlrd read_sheet =pd.read_excel('data.xlsx') #获取sheet表单,默认第一个 head_data =read_sheet.head() #读取前5行的数据,默认前5行 print(head_data) 阅读全文
posted @ 2020-11-04 15:20 fishing~ 阅读(97) 评论(0) 推荐(0)