import requests
import pytest
def test_1():
url1=1
url2=2
body={}
s=requests.session()#创建会话
print(s.headers)
r=requests.post(url1,json=body)
token=r.json()['token']
h={
'Auth':'Token %s' %token
} #获取登录返回toekn
#更新会话的头部,添加token
s.headers.update(h)
r2=s.request(url2,json=body)
#如果要把token传到body里,s是一个类,有token的属性
s.token=token
print(token)
浙公网安备 33010602011771号