用Python做测试——利用模块进行集中管理
来源:互联网 发布:显卡满载测试软件 编辑:程序博客网 时间:2024/05/21 10:31
新建account模块
#coding:utf-8
import requests
host = 'http://172.16.40.37:5000'
def test_username_exists(body):
url = host + '/cms/account/'
r = requests.get(url,params=body)
# 希望成功的数据检查
ifbody['expect'] ==True:
if r.status_code ==200 andr.json()['yes'] ==True:
print 'test sucess'
else:
print 'status_code=%s test_response=%s test_request=%s'% (r.status_code, r.json(),body)
else:
if r.status_code ==200 andr.json()['yes'] ==False:
print 'test sucess'
else:
print 'status_code=%s test_response=%s test_request=%s'% (r.status_code, r.json(),body)
def data_test_test_username_exists(body):
for data inbody:
test_username_exists(data)
新建data模块
body = [{'username_exists':'文字','expect':True,'case_no':'case001','case_pourpse':'检查用户名存在的返回'},\
{'username_exists':'notqwen','expect':False,'case_no':'case002','case_pourpse':'检查用户名不存在的返回'},\
{'username_exists':'notqweddddddddddddddddddddddddddddddddn','expect':False,'case_no':'case003','case_pourpse':'非法参数值攻击校验,大于指定长度20'},\
{'username_exists':"""~!@#$%%^^&**(){}:"<>?<script>alert('</script>""",'expect':False,'case_no':'case004','case_pourpse':"""非法参数值攻击校验,特殊字符~!@#$%%^^&**(){}:"<>?<script>alert('</script>"""},\
]
新建dataRunAccount模块
import account
import data
if "__name__"== "main":
# 测试username_exists的接口
account.data_test_test_username_exists(data.body)
- 用Python做测试——利用模块进行集中管理
- 利用log4j与sysLog 进行集中式日志管理
- 利用python做压力测试
- 利用python做ui测试
- 【Python】使用代码对redis的key进行集中管理
- 利用http模块进行post测试
- 用python做自动化测试--logging 和ConfigParser 模块
- beego利用casbin进行权限管理——第一节 起步、测试
- 对集群进行集中管理
- 使用python的nose模块进行测试
- 利用python做web自动化测试
- 用Velocity进行配置文件信息的集中管理
- 利用Python进行性能测试(上)
- 利用python进行性能测试(下)
- python模块——logging(日志管理)
- python模块——logging(日志管理)
- python模块——logging(日志管理)
- python模块——logging(日志管理)
- 第十六章 仅运行一次的工作排程(at)
- svn图标会存在延迟怎么办?还有不出现图标怎么办?
- Caffe GNU error
- 日志分片工具cronolog
- 第十六章 循环运行的例行性工作排程
- 用Python做测试——利用模块进行集中管理
- spring cloud网关zuul源码之Filter管理
- 第十六章 可唤醒停机期间的工作任务(anacron)
- mysql Multiversion Concurrency Control机制(mvcc)
- 折半查找
- 第十七章 什么是程序 (Process)
- Android Binder 全解析(1) -- 概述
- 第十七章 工作管理 (job control)
- 第十七章 程序管理