import requests
import pytest
@pytest.fixture(scope='session')
def login():
session = requests.Session()
url = "https: ......../login" # F12找接口url
data = {
# body里的参数.....
# "grantType": "",
# "key": "",
# "account": "",
# "password": "",
}
headers = {
# header里的属性
# "Authorization": "",
# "tenant": "",
"token": ""
}
res = session.request(method="post", url=url, json=data, headers=headers)
headers["token"] = res.json()['data']['token']
yield session, headers
pytest request.session 保持登录状态
于 2024-06-14 16:20:25 首次发布