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主项目出于运行状态,单元测试中可 ...
随机推荐
- 006-spring cloud gateway-GatewayAutoConfiguration核心配置-GatewayProperties初始化加载、Route初始化加载
一.GatewayProperties 1.1.在GatewayAutoConfiguration中加载 在Spring-Cloud-Gateway初始化时,同时GatewayAutoConfigur ...
- Kaggle案例泰坦尼克号问题
泰坦里克号预测生还人口问题 泰坦尼克号问题背景 - 就是那个大家都熟悉的『Jack and Rose』的故事,豪华游艇倒了,大家都惊恐逃生,可是救生艇#### 的数量有限,无法人人都有,副船长发话了l ...
- EXTJS4扩展实例:如何使用filter查询treepanel
我们在使用普通的store时,extjs提供了filterBy,filter等多种方法来过滤数据达到查询效果,但在treepanel中的streeStore却没有实现这个查询,于是,就有了这篇文章. ...
- unittest之suite测试集(测试套件)
suite 这个表示测试集,不要放在class内,否则会提示"没有这样的测试方法在类里面 ",我觉得它唯一的好处就是调试的时候可以单独调试某个class而已,我一般不用它,调试时可 ...
- AdaBoost Classifier和Regressor
Adaboost原理传送门 AdaBoost在我看理论课程的时候,以分类为例子来讲解的,谁知道sklearn里面基本上都有classifier和regressor两种.这个倒是我没想到的!!! fro ...
- 机器学习 python库 介绍
开源机器学习库介绍 MLlib in Apache Spark:Spark下的分布式机器学习库.官网 scikit-learn:基于SciPy的机器学习模块.官网 LibRec:一个专注于推荐算法的j ...
- 新浪微博 SAE
一.云平台中云是指互联网,网络的一种比喻说法,顾名思义,这种平台允许开发者们或是将写好的程序放在“云”里运行,或是使用“云”里提供的服务,或二者皆是. 二.开发类云平台比较: 1.鼻祖 GOOGLE ...
- python start
由于工作关系,新学习使用了python,感觉能非常快速和方便的开发,看完<简明 Python 教程>就跃跃欲试,实际用的是发现有些和C#的理解不一样 (1)如何筛选元组 例如 recor ...
- c# 日期函数[string.Format----GetDateTimeFormats]格式
DateTime dt = DateTime.Now;Label1.Text = dt.ToString();//2005-11-5 13:21:25Label2.Text = dt.ToFileTi ...
- presto 0.166概述
presto是什么 是Facebook开源的,完全基于内存的并⾏计算,分布式SQL交互式查询引擎 是一种Massively parallel processing (MPP)架构,多个节点管道式执⾏ ...