安装allure,配置环境变量标签:__,url,生成,header,json,allure,简单,data From: https://www.cnblogs.com/mmds/p/17171196.html
import os
import pytest
import requests
# 验证码登录
class TestLogin:
def test_login(self):
# 登录的地址
url = "http://192.168.2.79:1189/api/login/login/phone"
# 请求头
header = {
"content-typy": "application/json"
}
# 请求数据
data = {
"loginWay": 0, # 登录方式 0=验证码 1=手机号密码登录
"phone": "18283040959", # 手机号
"code": "", # 密码/验证码
"invitationCode": "" # 邀请Code 没有则不填
}
# 发送请求
requests.post(url=url, headers=header, data=data)
# 获取请求结果
res = requests.post(url=url, headers=header, json=data)
# 打印请求结果
print(res.json())
if __name__ == '__main__':
pytest.main(["-s","-q","testlogin.py","--alluredir","../report"])
os.system('allure serve ../report')
#os.system('allure generate ./pytest_case/temp -o report/html --clean')