http响应状态码测试脚本(python版)
来源:互联网 发布:自学java知乎 编辑:程序博客网 时间:2024/06/07 02:20
本人原创,转载请注明出处,合法转载!
#!/bin/evn python#Basic Test Case For Http Server#RangeYanimport requestsimport tracebackimport timeTestCaseIndex_Host_Mapping = {}TestCaseIndex_Url_Mapping = {}TestCaseIndex_Status_Code_Mapping = {}TestCaseIndex_Host_Mapping["1"] = "www.baidu.com"TestCaseIndex_Url_Mapping["1"] = "http://localhost/"TestCaseIndex_Status_Code_Mapping["1"] = "200"TestCaseIndex_Host_Mapping["2"] = "www.qq.com"TestCaseIndex_Url_Mapping["2"] = "http://localhost/"TestCaseIndex_Status_Code_Mapping["2"] = "200"TestCaseIndex_Host_Mapping["3"] = "www.taobao.com"TestCaseIndex_Url_Mapping["3"] = "http://localhost/"TestCaseIndex_Status_Code_Mapping["3"] = "200"########### Start from this ##########print "Start Basic Test For Http Server..."Success_count = 0False_count = 0for index in range(1,len(TestCaseIndex_Url_Mapping)+1): try : url = TestCaseIndex_Url_Mapping[str(index)] headers = {} headers['Host'] = TestCaseIndex_Host_Mapping[str(index)] r = requests.get(url, headers=headers,allow_redirects=False) if TestCaseIndex_Status_Code_Mapping[str(index)] != str(r.status_code): print "Test Case",index,": False" print " Request Url:",url print " Request Headers:",headers print " Right Response Status Code:",TestCaseIndex_Status_Code_Mapping[str(index)] print " Actual Response Status Code:",r.status_code False_count += 1 else : print "Test Case",index,": Success" Success_count += 1 except Exception , e: print e traceback.print_exc() time.sleep(0.1)print "End Basic Test For Http Server..."print "*************************************"print "Sumarry:" print " Success:",Success_countprint " False: ",False_countprint "*************************************"
0 0
- http响应状态码测试脚本(python版)
- Python HTTP响应状态码
- http响应状态码
- HTTP状态响应码
- HTTP 响应状态码
- HTTP 响应状态码
- http响应状态码
- http响应状态码
- HTTP 响应状态码
- http状态响应码
- http响应状态码
- HTTP 状态响应码
- http状态响应码
- HTTP响应状态码
- HTTP响应状态码
- HTTP 状态响应码
- HTTP响应状态码
- HTTP 状态响应码
- 使用ThreadLocal编写HibernateUtil工具类
- swift笔记之新项目中navigationController的创建和初始化
- 正益工场,构建社区型移动众包平台
- oracle数据库创建用户和IAR编译器读取数据的问题
- Mysql中查找并删除重复数据的方法
- http响应状态码测试脚本(python版)
- STL算法库-排序和相关操作(一)
- Codeforces Round #336 (Div. 2)B. Hamming Distance Sum
- windows7下eclipse连接ubuntu中的hadoop开发环境配置
- 自定义图片轮播控件
- eclipse maven 插件的安装和配置
- HP云计算产品和解决方案一览
- 2-10-归并扩展的线性单链表-线性表-第2章-《数据结构》课本源码-严蔚敏吴伟民版
- 集算器和R语言处理外存文本文件的对比