# coding=utf-8 import requests import pytest """ /* @param: version: python3.7 pip install pytest pip install pytest-html */ """ class GetInitParams(object): def __init__(self): self.url="xxx" self.header="xxx" self.data="xxx" self.param="xxx" self.cookie-"xxx" self.session="xxx" self.method="xxx" self.json="xxx" @pytest.fixture(scope="class") def dt(): return GetInitParams() class TestApi(object): def test_api001(self,dt): res=requests.post(url=dt.url,headers=dt.header,data=dt.data,cookie=dt.cookie).json() print(res.text) #py2.x res.content assert res.status_code==200 def test_api002(self,dt): res=requests.post(url=dt.url).json() token=res["token"] print(res.text,token)