一、附件类型
| 类型 |
类型值 |
| 文本 |
allure.attachment_type.TEXT |
| CSV |
allure.attachment_type.CSV |
| 图片 |
allure.attachment_type.JPG或PNG |
| PDF |
allure.attachment_type.PDF |
| html文件 |
allure.attachment_type.HTML |
| json文件 |
allure.attachment_type.JSON |
| xml文件 |
allure.attachment_type.XML |
| mp4 |
allure.attachment_type.MP4 |
二、添加字符串附件
allure.attach(body,name,attachment_type,extention)
| 参数名 |
含义 |
举例 |
| body |
要添加的内容 |
如response.json() |
| name |
附件的文件名 |
如响应报文 |
| attachment_type |
如text,见附件类型 |
见类型表 |
| extention |
附件保存的文件后缀(可不填) |
|
二、示例
class TestSignUp:
def login(self):
url = ''
req = {
"pwd": "string",
"userName": "string"
}
allure.attach(req, '请求', allure.attachment_type.TEXT)
resp = requests.post(url, json=req)
allure.attach(resp.text, '响应', allure.attachment_type.TEXT)
三、查看报告