!/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的更多相关文章

  1. 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 ...

  2. python - 接口自动化测试 - TestLogin - 登录接口测试用例

    # -*- coding:utf-8 -*- ''' @project: ApiAutoTest @author: Jimmy @file: test_login.py @ide: PyCharm C ...

  3. AttributeError: 'TestLogin' object has no attribute 'driver' in Pycharm for python selenium

    自动化测试学习中的问题: 最近几天在写登陆测试,遇到一个问题,困惑我的几个小时......... 我各种百度,花费大量时间,才找到我的问题的根本所在,最终解决了我的问题,主要是大小写的问题def Se ...

  4. springmvc配置文件web.xml详解各方总结(转载)

    Spring分为多个文件进行分别的配置,其中在servlet-name中如果没有指定init-param属性,那么系统自动寻找的spring配置文件为[servlet-name]-servlet.xm ...

  5. TestNG 入门教程

    原文出处:http://www.cnblogs.com/TankXiao/p/3888070.html 阅读目录 TestNG介绍 在Eclipse中在线安装TestNG 在Eclipse中离线安装T ...

  6. SQL注入

    @org.junit.Test public void testLogin() { CardDAO cd=new CardDAO(); if(cd.dengru("' or 1 = 1--& ...

  7. SpringMVC和MyBatis整合

    目前主流的Web MVC框架,除了Struts这个主力 外,还有Spring MVC,主要是由于Spring MVC配置比较简单,使用起来也十分明了,非常灵活,与Spring 集成较好,对RESTfu ...

  8. Android开源测试框架学习

    近期因工作需要,分析了一些Android的测试框架,在这也分享下整理完的资料. Android测试大致分三大块: 代码层测试 用户操作模拟,功能测试 安装部署及稳定性测试 代码层测试 对于一般java ...

  9. 通过单元测试理解spring容器以及dubbo+zookeeper单元测试异常处理

    一.先说一个结论:单元测试与主项目的spring容器是隔离的,也就是说,单元测试无法访问主项目spring容器,需要自己加载spring容器. 接下来是代码实例,WEB主项目出于运行状态,单元测试中可 ...

随机推荐

  1. api文档生成器apidoc的安装和使用

    在开发接口的过程中,需要向外发布相应的接口文档.开始的时候使用word来写文档,时间长了发现有几个问题. 1. 编写不方便.每次新增借口的时候都要复制上一个接口,然后再进行修改,一些相同的部分无法复用 ...

  2. [sql]mysql管理手头手册,多对多sql逻辑

    各类dbms排名 cs模型 mysql字符集设置 查看存储引擎,字符集 show variables like '%storage_engine%'; show VARIABLES like '%ma ...

  3. 测试人员需要了解的sql知识(提高篇)

    上一篇写了一些基础的sql知识,这里再深挖一些常用的 ------------------------------------------------------------------骄傲的分割线- ...

  4. ArrayList(JDK1.9)

    一.ArrayList概念. 1.数据结构.它是一个数组,可以动态增长的数组. 2.继承实现关系图.继承抽象List,实现List.随机方法.克隆.序列化. 3. 二.内部类. final class ...

  5. SoapUI 使用变量

    登录问题不好解决, 只能临时用cookie来执行 1.变量定义 2.引用变量 3.调用Header

  6. mysql事务(二)——控制语句使用

    事务控制 一般来说,mysql默认开启了事务自动提交功能,每条sql执行都会提交事务.可以使用如下语句关闭事务自动提交功能. show session variables like 'autocomm ...

  7. iframe嵌套

    iframe基本内涵 通常我们使用iframe直接直接在页面嵌套iframe标签指定src就可以了. <iframe src="demo_iframe_sandbox.htm" ...

  8. 返回xml过长时被nginx截断的解决办法

    返回xml过长时被nginx截断的解决办法 问题描述:通过网页获取数据,数据格式为xml.当xml比较短时,可以正常获取数据.但是xml长度过长时不能正常获取数据,通过观察返回数据的源代码,发现xml ...

  9. C++中公有继承、保护继承、私有继承的区别

    公有继承时基类中各成员属性保持不变,基类中private成员被隐藏.派生类的成员只能访问基类中的public/protected成员,而不能访问private成员:派生类的对象只能访问基类中的publ ...

  10. bzoj1634 / P2878 [USACO07JAN]保护花朵Protecting the Flowers

    P2878 [USACO07JAN]保护花朵Protecting the Flowers 难得的信息课......来一题水题吧. 经典贪心题 我们发现,交换两头奶牛的解决顺序,对其他奶牛所产生的贡献并 ...