testlogin
!/usr/bin/env python
coding:utf-8
import requests
import unittest
import json,urllib
class testlogin(unittest.TestCase):
def Test_login(self):
'''
测试登录接口
'''
url='http://loan-customer.test.91gfd.cn/auth/local'
identifier ='admin'
password = 'admin'
next = ''
headers ={
'Content-Type': 'application/x-www-form-urlencoded'
}
data = {
'identifier':identifier,
'password':password,
'next':next
}
response = requests.post(url, data=data, headers=headers)
#assert response['success'] == True
print(response.status_code)
assert (response.status_code) == 200
#print(response.content)
print(response.text)
#print(response.encoding)
!/usr/bin/env python
coding:utf-8
import requests
import unittest
import json,urllib
try:
from urlparse import urljoin
except ImportError:
from urllib.parse import urljoin
'''
把登录接口的调用封装到一个方法
url参数化
'''
class loginApi(object):
def init(self):
self.base_url ='http://loan-customer.test.91gfd.cn/'
print('765432')
def login(self,identifier,password,next):
#identifier:用户名;password:密码
url=urljoin(self.base_url,'auth/local')
headers = {
'Content-Type':'application/x-www-form-urlencoded'
}
data = {
'identifier':identifier,
'password':password,
'next':next
}
print('8888888')
req=requests.post(url,data=data,headers=headers)
return (req)
print('2222')
class Testlogin(unittest.TestCase):
def Test_login(self):
'''
测试登录接口
'''
identifier='admin'
password='admin'
next=''
response = loginApi().login(identifier,password,next)
print('1234')
print(response.status_code)
print(response.text)
testlogin的更多相关文章
- ddt运行报错AttributeError: type object 'TestLogin' has no attribute 'test_login'
源代码: #!usr/bin/python3 # -*- coding:utf-8 -*- # @Time: 2018/12/17 下午2:07 # @File: do_excel.py # @Sof ...
- python - 接口自动化测试 - TestLogin - 登录接口测试用例
# -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: test_login.py @ide: PyCharm C ...
- AttributeError: 'TestLogin' object has no attribute 'driver' in Pycharm for python selenium
自动化测试学习中的问题: 最近几天在写登陆测试,遇到一个问题,困惑我的几个小时......... 我各种百度,花费大量时间,才找到我的问题的根本所在,最终解决了我的问题,主要是大小写的问题def Se ...
- springmvc配置文件web.xml详解各方总结(转载)
Spring分为多个文件进行分别的配置,其中在servlet-name中如果没有指定init-param属性,那么系统自动寻找的spring配置文件为[servlet-name]-servlet.xm ...
- TestNG 入门教程
原文出处:http://www.cnblogs.com/TankXiao/p/3888070.html 阅读目录 TestNG介绍 在Eclipse中在线安装TestNG 在Eclipse中离线安装T ...
- SQL注入
@org.junit.Test public void testLogin() { CardDAO cd=new CardDAO(); if(cd.dengru("' or 1 = 1--& ...
- SpringMVC和MyBatis整合
目前主流的Web MVC框架,除了Struts这个主力 外,还有Spring MVC,主要是由于Spring MVC配置比较简单,使用起来也十分明了,非常灵活,与Spring 集成较好,对RESTfu ...
- Android开源测试框架学习
近期因工作需要,分析了一些Android的测试框架,在这也分享下整理完的资料. Android测试大致分三大块: 代码层测试 用户操作模拟,功能测试 安装部署及稳定性测试 代码层测试 对于一般java ...
- 通过单元测试理解spring容器以及dubbo+zookeeper单元测试异常处理
一.先说一个结论:单元测试与主项目的spring容器是隔离的,也就是说,单元测试无法访问主项目spring容器,需要自己加载spring容器. 接下来是代码实例,WEB主项目出于运行状态,单元测试中可 ...
随机推荐
- react.js 之 create-react-app 命令行工具系统讲解
react.js 教程之 create-react-app 命令行工具系统讲解 快速开始 npm install -g create-react-app create-react-app my-app ...
- [GDAL]写入shp
C#通过Wkt码构建shp,记录写不进去! static void WriteVectorFile() { string strVectorFile = "E:\\"; // 注册 ...
- 人活着系列之开会(Floy)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2930 题意:所有点到Z点的最短距离.因为岛名由 ...
- 4.keras实现-->生成式深度学习之用GAN生成图像
生成式对抗网络(GAN,generative adversarial network)由Goodfellow等人于2014年提出,它可以替代VAE来学习图像的潜在空间.它能够迫使生成图像与真实图像在统 ...
- js中sort()方法冒泡排序模拟
1.sort()方法概述 sort() 方法用于对数组的元素进行排序. 如果调用该方法时没有使用参数,将按字母顺序对数组中的元素进行排序,说得更精确点,是按照字符编码的顺序进行排序.要实现这一点, 首 ...
- MySQL从删库到跑路_高级(一)——数据完整性
作者:天山老妖S 链接:http://blog.51cto.com/9291927 一.数据完整性简介 1.数据完整性简介 数据冗余是指数据库中存在一些重复的数据,数据完整性是指数据库中的数据能够正确 ...
- Selenium2+python自动化54-unittest生成测试报告(HTMLTestRunner)
前言 批量执行完用例后,生成的测试报告是文本形式的,不够直观,为了更好的展示测试报告,最好是生成HTML格式的. unittest里面是不能生成html格式报告的,需要导入一个第三方的模块:HTMLT ...
- Linux服务器---apache支持SSL
Apache支持ssl 1.检测是否安装ssl模块,如果没有就安装 [root@localhost cgi-bin]# rpm -qa | grep mod_ssl //查看是否安 ...
- JS实现仿腾讯微博无刷新删除微博效果代码
这里演示JS仿腾讯微博无刷新删除效果,将显示在微博列表里的内容删除,运用AJAX技术,无刷新删除微博的内容,参考性强,希望对初学AJAX的朋友有所帮助. 在线演示地址如下: http://demo.j ...
- c++第十七天
p101~p104: 1.数组中的元素个数也属于数组类型的一部分. 2.编译的时候数组的维度应该是已知的,也就是说维度必须是 const expression 3.const expression 是 ...