python接口测试

使用python进行组织编写接口测试用例

  • 接口测试其实就是几个步骤。
  1. 拿到接口的url地址
  2. 查看接口是用什么方式发送
  3. 添加请求头,请求体
  4. 发送查看返回结果,校验返回结果是否正确

一个hello,world程序

#-*- coding:utf-8 -*-
import bottle
from bottle import run, route, response

@route('/hello/:a')
def hello(a):
    return 'hello world.nihaosdfasd'+a
bottle.run( host='0.0.0.0', port=8081)

启动后在浏览器输入:

http://localhost:8081/hello/ABSK

则输出结果为:

hello world.nihaosdfasdABSK
原文地址:https://www.cnblogs.com/monkey-moon/p/9220725.html