!/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. ABAP抓取异常的方法:try,endtry

    部分转自:http://www.cnblogs.com/jiangzhengjun/p/4292428.html +4.Funcion函数异常处理 说明: 异常处理机制可以有效避免 dump发生, : ...

  2. np.repeat 与 np.tile

    1.Numpy的 tile() 函数,就是将原矩阵横向.纵向地复制.tile 是瓷砖的意思,顾名思义,这个函数就是把数组像瓷砖一样铺展开来. 举个例子,原矩阵: import numpy as np ...

  3. http协议基础(十一)http与https

    一.http的缺点 之前有介绍过http协议相关的一些知识,http是相当优秀和方便的,但它也有缺点,主要不足表现在如下几个方面: △ 通信使用明文(不加密),内容可能会被窃听 △ 不验证通信方的身份 ...

  4. 第一章SpringBoot入门

    一.简介 SpringBoot来简化Spring应用的开发,约定大于配置,去繁从简,just run就能创建一个独立的产品级别的应用. 背景: j2EE笨重的开发方法,繁多的配置,低下的开发效率,复杂 ...

  5. swoole线程和进程

    pstree -a | grep php |   |       `-php server.php   主进程      |   |           |-php server.php   管理线程 ...

  6. UVM环境(一)

    1)如何避免绝对路径的出现:绝对路径一般都是用在信号的连接关系上,这样可以用virtual interface,来通过句柄的赋值来动态的建立连接关系.那么顶层模块怎么 样将interface的句柄赋值 ...

  7. linux导出、导入sql

    linux下导入.导出mysql数据库命令 一.导出数据库用mysqldump命令(注意mysql的安装路径,即此命令的路径): 1.导出数据和表结构: mysqldump -u用户名 -p密码 数据 ...

  8. nginx之rewrite重写,反向代理,负载均衡

    rewrite重写(伪静态): 在地址栏输入xx.com/user-xxx.html, 实际上访问的就是xxx.com/user.php?id=xxx rewrite就这么简单 附上ecshop re ...

  9. 最短路径-----迪杰斯特拉算法(C语言版)

    原文:http://blog.csdn.net/mu399/article/details/50903876 转两张思路图非常好:   描述略   图片思路很清晰.  Dijkstra不适用负权值,负 ...

  10. PHP读取sphinx 搜索返回结果完整实战实例

    PHP读取sphinx 搜索返回结果完整实战实例 网上搜索N久都没有一个正在读取返回sphinx结果的实例,都是到了matches那里就直接var_dump或者print_r了,没有读取到字段的例子, ...