
Python接口测试
文章平均质量分 95
up1292
从事软件测试十多年,一直浑浑噩噩的,总想提高技术,学习的东西很多很杂,但都不深入。感叹自己水平有限能力一般,勉强在这行混饭吃。记录下自己的学习过程,主要是给自己看的,所以写的很乱,如果能给阅读者一丝丝帮助,那也是您自己的努力。
展开
-
python接口测试中关于乱码的解决方法
requests对象的get和post方法都会返回一个Response对象我使用了.text方法查看,发现接口返回的中文是乱码,用postman测了一下,返回是正常的。然后研究了一下编码的知识,想使用decode("utf-8")方法来解码,结果发现.text中没有decode()方法。然后用.content方法,发现有decode()方法使用了content来查看,会发现前面存在...原创 2019-11-21 10:59:11 · 823 阅读 · 0 评论 -
Python接口测试之requests模块详解
本篇将介绍如何使用Requests来做接口测试首先先确认一下事情:Requests isinstalled Requests isup-to-date先从一些简单的例子开始。创建一个请求用Requests来创建一个请求是很简单的。先导入Requests模块:>>> import requests我们来尝试获取一个网页。看以下例子:&g...原创 2019-09-24 10:06:13 · 1074 阅读 · 0 评论 -
Python 连接MySQL的操作
python2中需要导入MySQLdb模块,python3中需要导入pymysql模块# coding=utf-8__date__ = '2019/9/12 10:24'__author__ = 'Allen'import pymysqlclass OperationMysql: def __init__(self): self.conn = pymys...原创 2019-09-12 11:05:57 · 115 阅读 · 0 评论 -
jenkins环境搭建和项目配置简单记录
1、下载jenkins到官网https://jenkins.io/zh/,下载windows版本下的jenkins2、安装jenkins直接点击安装文件安装,一路next,安装完后会自动打开http://localhost:8080遇到插件无法安装的情况,在浏览器中打开http://localhost:8080/pluginManager/advanced将升级站点中的http...原创 2019-08-22 15:57:50 · 127 阅读 · 0 评论 -
python读取excel
1、导入模块 import xlrd2、打开Excel文件读取数据 data = xlrd.open_workbook('excel.xls')3、获取一个工作表① table = data.sheets()[0] #通过索引顺序获取(不建议使用,因为用table.显示不了方法)② table = data.sheet_by_index(0) #通过索引顺...原创 2019-08-12 16:40:46 · 233 阅读 · 0 评论 -
python load json文件的报错处理
在windows系统下,创建了一个txt文本文件,写入字符串,保存为utf-8的编码格式。然后修改后缀为.json。用以下代码load这个json文件import jsonwith open(r"./file/test3.json", "r", encoding="utf-8") as f: data = json.load(f) print(data)结果报了如...原创 2019-08-15 22:07:28 · 3058 阅读 · 0 评论 -
对excel操作进行简单的封装
使用xlrd和xlutils.copy,把取excel的行数、列数、行值、列值、单元格值和写入已有的excel都做了封装。# coding=utf-8__date__ = '2019/8/15 8:47'__author__ = 'Allen'import xlrdfrom xlutils.copy import copyclass OperExcel: """ ...原创 2019-08-15 15:32:50 · 3272 阅读 · 0 评论 -
Python 使用smtplib构建发送邮件服务
# coding=utf-8__date__ = '2019/8/18 10:47'__author__ = 'Allen'import smtplibfrom email.mime.text import MIMETextclass SendMail: def send_mail(self, receivers, subject, content): s...原创 2019-08-19 17:06:21 · 294 阅读 · 0 评论 -
unittest中case的管理及运用
import unittestclass Testdemo(unittest.TestCase): def test_01(self): print("这是第一个case") # @unittest.skip('test_02') # test_02不执行 def test_02(self): print("这是第二个case...原创 2019-08-08 20:10:06 · 557 阅读 · 0 评论 -
unittest简单使用
import unittestclass TestMethod(unittest.TestCase): #在所有case执行之前执行 @classmethod def setUpClass(cls): print ('In front of all the cases, and just run once.') #在所有case执行之后执行...原创 2019-05-10 15:51:30 · 312 阅读 · 0 评论 -
将GET和POST合并
import requestsimport jsondef send_get(url,data): res = requests.get(url=url,data=data) returen json.dumps(res,indent=2,sort_keys=True) def send_post(url,data): res = requests.pos...原创 2019-05-10 15:32:48 · 521 阅读 · 0 评论 -
Python接口测试:POST请求测试,登录获取token
# Author: Allenleeimport requests#测试用户名密码data = { "key":"allen", "password":"123456"}#测试的接口地址url = "http://test-lcfc.testline.cn:5555/api/account/api/lcfc/account/login"#返回值res = ...原创 2019-04-21 19:09:09 · 4733 阅读 · 0 评论