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主项目出于运行状态,单元测试中可 ...
随机推荐
- 8 jmeter之集合点
集合点:集合点用以同步虚拟用户,以便恰好在同一时刻执行任务.在测试计划中,可能会要求系统能够承受1000 人同时提交数据,在LoadRunner 中可以通过在提交数据操作前面加入集合点,这样当虚拟用户 ...
- 图片预览-兼容IE
直接贴代码吧: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www ...
- ubuntu 磁盘分区
1:查看分区情况:df -h admin@iZwz92c0zpe8t65qe996ckZ:/$ df -h Filesystem Size Used Avail Use% Mounted on ude ...
- mysql的count方法详解
1.cout(*)会统计为null的行: 2.count(列名)不会统计此列null值的行: 3.count(distinct col)计算该列除null之外的不重复数量:
- font-awesome图标
- IO(File)
1. 一个File类的对象,表示了磁盘上的文件或目录 2. File类提供了与平台无关的方法来对磁盘上的文件或目录进行操作 3. File对象可用来获取或处理与磁盘文件相关的信息,如:权限,时间,日期 ...
- Linux基础命令---lsattr
lsattr 显示指定文件或者目录的属性. 此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法 lsattr [选项 ...
- php CI 实战教程第一季百度经验杂志
phpCI实战教程第一季_百度经验杂志_百度经验http://jingyan.baidu.com/magazine/16428 杂志为本人php CI实战教程系列经验 从实际项目使用中写系列实战经验, ...
- MongoDB— 细说操作
基本操作 由于是开篇,就大概的说下基本的“增删查改“,我们再开一个cmd,输入mongo命令打开shell,其实这个shell就是mongodb的客户端, 同时也是一个js的编译器,默认连接的是“te ...
- RPC框架原理剖析(含实例)(转)
转自:http://blog.csdn.net/rulon147/article/details/53814589 一.什么是RPC RPC(Remote Procedure Call Protoco ...