python.制图.饼状图

1

def sendMsgtemplate_card(fail,passnum,casename,casetime,path):

    import pandas as pd
    import matplotlib.pyplot as plt
    # 将测试结果转换为数值类型
    data1 = {'errors': '0', 'failures': fail, 'skipped': '1', 'tests': casename}
    data1 = {k: int(v) for k, v in data1.items()}

    # 计算测试结果的比例
    failures_ratio = data1['failures'] / data1['tests']
    success_ratio = 1 - failures_ratio

    # 创建饼状图
    fig, ax = plt.subplots()
    ax.pie([failures_ratio, success_ratio], labels=['Failures', 'Success'], autopct='%1.1f%%', startangle=90)
    ax.set_title('Test Results')
    plt.savefig('save.jpg')
    plt.show()
    import time

if __name__=="__main__":
    sendMsgtemplate_card('5','5','111','55',"allure-report_20230524_111555/index.html")

2

3

image

posted @ 2023-06-21 14:01  测试-连环  阅读(10)  评论(0编辑  收藏  举报
访问主页 w