接口测试demo
Posted dudubao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了接口测试demo相关的知识,希望对你有一定的参考价值。
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的主要内容,如果未能解决你的问题,请参考以下文章