首页 > 其他 > 详细

接口测试demo

时间:2018-08-30 00:39:27      阅读:227      评论:0      收藏:0      [点我收藏+]
import requests
import json
class Run_main():
    def __init__(self, url, method, data=None):
        self.re = self.run_main(url, method, data=None)

    def send_get(self, url, data):
        re = requests.get(url, data).json()
        return json.dumps(re, indent=2, sort_keys=True)

    def send_post(self,url, data):
        re = requests.post(url, data).json()
        return json.dumps(re, indent=2, sort_keys=True)

    def run_main(self, url, method, data=None):
        res = None
        if method == ‘GET‘:
            res = self.send_get(url, data)
        else:
            res = self.send_post(url, data)
        return res


if __name__ == ‘__main__‘:
    url = ‘‘
    data = {
        ‘marking‘: ‘‘,
        ‘secrect‘: ‘‘,
        ‘timestamp‘: ‘‘,
        ‘token‘: ‘‘,
        ‘uid‘: ‘0‘
    }
    runner = Run_main(url, ‘POST‘, data)
    print(runner.re)

  

接口测试demo

原文:https://www.cnblogs.com/dudubao/p/9557624.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!