当前位置: 首页 > news >正文

Allure报告下载不同格式的文件

支持类型: 

class AttachmentType(Enum):def __init__(self, mime_type, extension):self.mime_type = mime_typeself.extension = extensionTEXT = ("text/plain", "txt")CSV = ("text/csv", "csv")TSV = ("text/tab-separated-values", "tsv")URI_LIST = ("text/uri-list", "uri")HTML = ("text/html", "html")XML = ("application/xml", "xml")JSON = ("application/json", "json")YAML = ("application/yaml", "yaml")PCAP = ("application/vnd.tcpdump.pcap", "pcap")PNG = ("image/png", "png")JPG = ("image/jpg", "jpg")SVG = ("image/svg-xml", "svg")GIF = ("image/gif", "gif")BMP = ("image/bmp", "bmp")TIFF = ("image/tiff", "tiff")MP4 = ("video/mp4", "mp4")OGG = ("video/ogg", "ogg")WEBM = ("video/webm", "webm")PDF = ("application/pdf", "pdf")

使用方法

@allure.title("Test with CSV attachment")
def test_with_xlsx_attachment1():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/excel_example.csv'with open(file_path, 'rb') as f:allure.attach(f.read(), name="MyCSVAttachment", attachment_type=allure.attachment_type.CSV)# 测试逻辑assert True@allure.title("Test with TXT attachment")
def test_with_xlsx_attachment2():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/file1.txt'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My txt Attachment", attachment_type=allure.attachment_type.TEXT)# 测试逻辑assert True@allure.title("Test with LOG attachment")
def test_with_xlsx_attachment3():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/file2.log'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My txt Attachment", attachment_type=allure.attachment_type.TEXT)# 测试逻辑assert True@allure.title("Test with HTML attachment")
def test_with_xlsx_attachment4():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/BigDataplotly.html'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My txt Attachment", attachment_type=allure.attachment_type.HTML)# 测试逻辑assert True@allure.title("Test with JPG attachment")
def test_with_xlsx_attachment5():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/image.jpg'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My jpg Attachment", attachment_type=allure.attachment_type.JPG)# 测试逻辑assert True@allure.title("Test with PCAP attachment")
def test_with_xlsx_attachment6():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/10020_10021_5000_93_138651_3.pcap'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My jpg Attachment", attachment_type=allure.attachment_type.PCAP)# 测试逻辑assert True@allure.title("Test with YAML attachment")
def test_with_xlsx_attachment7():# Allure测试报告添加附件file_path = 'D:/code/AutoTest/TestDatas/ModelE/test_varArgs.yml'with open(file_path, 'rb') as f:allure.attach(f.read(), name="My yaml Attachment", attachment_type=allure.attachment_type.YAML)# 测试逻辑assert True

结果展示

下载


http://www.mrgr.cn/news/18934.html

相关文章:

  • redis缓存和数据库通过延迟双删除实现数据一致性
  • 基于Bert-base-chinese训练多分类文本模型(代码详解)
  • 为什么说2025年是国自然申请最佳时机?
  • Centos根目录扩容Docker分区扩容最佳实践
  • MySQL备份与恢复
  • 鸿蒙开发占多列的瀑布流
  • 商务文件的八大翻译需求
  • 短剧APP遭遇DDoS攻击的解决方法
  • 代码随想录打卡第10天
  • 前端框架大观:探索现代Web开发的基石
  • 算法:当一系列数据经过四舍五入后,总和不再等于100%时
  • 图论题总结
  • 数据结构————单向链表
  • Kettle 锁表原因及解决办法【源码级分析】
  • Python数据分析实战,兰州市二手房市场深度分析
  • 4款电脑数据恢复软件分享,告别天价恢复!
  • Pyspark中catalog的作用与常用方法
  • Java中的双亲委派模型以及如何破坏双亲委派
  • Elasticsearch检索原理
  • java:线程池