import requestsimport unittest class TestQQ(unittest.TestCase):    '''测试QQ号接口'''      # 此注释将展示到测试报告的测试组类 def test_qq(self):        '''测试QQ号码,正确的appkey'''      # 此注释将展示到测试报告的用例标题        url = 'http://japi.juhe.cn/qqevaluate/qq'        par = {     …
 #!/usr/bin/env python# -*- coding: utf-8 -*-# @Time    : 2018/5/28 18:51# @Author  : StalloneYang# @File    : mysql_test.py# @desc: # 连接数据库 import pymysql.cursors # 连接MySQL数据库connection = pymysql.connect(host='localhost', port=3306, user='yang', pas…
# 先安装ruamel.yaml模块 写入配置文件: import os# 先安装ruamel.yaml模块from ruamel import yaml # 将字典写入到yamldict = { 'host1': '123', 'host2': '456', 'host3': '789', 'host4': '147', 'host5': {'asd': '123'} } curpath = os.path.dirname(os.path.realpath(__file__))yamlpath…
1.中文乱码问题: (1).文件头加上# -*- coding:utf-8 -*- 或者 #coding=utf8 (2).pymssql.connect连接串中charset是要跟你数据库的编码一样,如果是数据库是gb2312 ,则写charset='gb2312'. (3).读取数据时需要decode('utf-8'),写入数据时需要encode('utf-8'),这样就可以避免中文乱码或报错问题. 2.需要安装pymssql包(连接mysql安装pymysql) pip install p…
GitHub传送门:https://github.com/TesterlifeRaymond/BeautifulReport 配置BeautifulReport 下载.解压并修改名字为BeautifulReport: 把BeautifulReport文件夹复制放到python安装目录下的site-packages下,如我的目录: 在BeautifulReport/sample下,运行sample.py文件,出现以下结果,则说明BeautifulReport的配置已可用 接下来使用到项目上…
# 添加多个附件参数化files = [("1.png", "1.png") ("2.png", "2.png") ]def addFiles(files, n=1): file = [] for i in list(range(n)): a =("files[]", (files[i][1], open(files[i][2], "rb"), "image/png"…
文件下载类型: Content-Type: octets/stream   一般为文件类型:…
# coding:utf-8import requestsimport refrom bs4 import BeautifulSoup # s = requests.session() # 全局的s def get_token(s): ''' fuction: 获取token args: s 参数 ->s = requests.session() :return anti_token ->{'X-Anit-Forge-Token': 'xx', 'X-Anit-Forge-Code': '38…
python接口自动化测试二十七:密码MD5加密   ''' MD5加密 '''# 由于MD5模块在python3中被移除# 在python3中使用hashlib模块进行md5操作import hashlib # 待加密信息str = 'asdas89799,.//plrmf'# 创建md5对象hl = hashlib.md5()# Tips# 此处必须声明encode# 若写法为hl.update(str) 报错为: Unicode-objects must be encoded before…
接口类 继承有两种用途:继承基类的方法,并且做出自己的改变或扩展(代码重用)和声明某个子类兼容于某基类,定义一个接口类interface,接口类中定义了一些接口名(就是函数名)且并未实现接口的功能,子类继承接口类,并且实现接口的功能 比如说一种支付方式有三种不同的途径:Alipay.Applepay.Wechatpay 如果现在只有两种支付方式Alipay和Wechatpay,我们该如何去实现支付的方法呢? class Wechat: def pay(self,money): print('已经…