为了账号安全,请及时绑定邮箱和手机立即绑定

接口测试报错 求解?

/ 猿问

接口测试报错 求解?

aimike 2019-07-15 23:28:26

import unittest

import json

from demo import RunMain


class TestMethod(unittest.TestCase):


def setUp(self):

self.run=RunMain()


def test_01(self):

url='http://api-app.meizu.com/apps/public/category/layout'

data={

"custom_icon":"1",

"device_model":"M57AC",

"firmware":"Flyme OS 5.1.0.6QY",

"imei":"868905020250933",

"language":"zh-CN",

"locale":"CN",

"max":"50",

"mpv":"appsv5",

"mzos":"5",

"net":"wifi",

"os":"22",

"screen_size":"1080x1920",

"sn":"A1CEBN3223GS",

"start":"0",

"v":"5.0.8",

"vc":"210"

}


# run=RunMain()


res=self.run.run_main(url,'POST',data)

print res


def test_02(self):

url='http://api-app.meizu.com/apps/public/category/layout'

data={

"custom_icon":"1",

"device_model":"M57AC",

"firmware":"Flyme OS 5.1.0.6QY",

"imei":"868905020250934",

"language":"zh-CN",

"locale":"CN",

"max":"50",

"mpv":"appsv5",

"mzos":"5",

"net":"wifi",

"os":"22",

"screen_size":"1080x1920",

"sn":"A1CEBN3223GS",

"start":"0",

"v":"5.0.8",

"vc":"210"

}


res=self.run.run_main(url,'POST',data)

print res


if __name__ == '__main__':

unittest.main()

——————————————————————————————————————————————

#coding=utf-8

import json

import requests



class RunMain:


def __init__(self,url,method,data=None):

self.res=self.run_main(url,method,data)


def send_get(self,url,data):

res=requests.get(url=url,data=data).json()

return json.dumps(res,indent=2,sort_keys=True)



def send_post(self,url,data):

res=requests.post(url=url,data=data).json()

return json.dumps(res,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='http://api-app.meizu.com/apps/public/category/layout'

data={

"custom_icon":"1",

"device_model":"M57AC",

"firmware":"Flyme OS 5.1.0.6QY",

"imei":"868905020250933",

"language":"zh-CN",

"locale":"CN",

"max":"50",

"mpv":"appsv5",

"mzos":"5",

"net":"wifi",

"os":"22",

"screen_size":"1080x1920",

"sn":"A1CEBN3223GS",

"start":"0",

"v":"5.0.8",

"vc":"210"

}

run=RunMain(url,'POST',data)

print run.res

# print run.run_main(url,'POST',data)



https://img2.mukewang.com/5d2c9b790001c85807910417.jpg

查看完整描述

目前暂无任何回答

添加回答

回复

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信