在conftest.py文件中的pytest修饰器:
@pytest.fixture(scope='session')#做标志,确定使用域
#定义一个方法获取token,方法返回值为token
def token():
url = 'http://www.guoyasoft.com:8084/login'
req = {
"pwd": "9CBxL4j0",
"userName": "kanglc23"
}
resp = request_tool.post_json(url, json=req)
resp_json = json.loads(resp.text)
token = resp_json['data']['token']
return token
网友评论