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

python自动化测试模板

1:准备html模版

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

<!DOCTYPE html>

<html>

<head>

    <meta charset="utf-8">

    <title>接口自动化</title>

</head>

<body style="margin-top: 20px; font-style: '微软雅黑';">

<table border="1" cellspacing="0" cellpadding="5" width="100%" align="center">

    <tr bgcolor="bisque" style="font-style: 30px">

        <td height="60" colspan="5">

            自动化测试报告:&test_data

             

        </td>

    </tr>

    <tr style="font-style: 20px">

        <td width="20%">被测版本:&version</td>

        <td width="15%">成功:&pass</td>

        <td width="15%">失败:&fail</td>

        <td width="15%">错误:&error</td>

        <td width="30%">最后时间:&lasttime</td>

    </tr>

</table>

<p></p>

<table border="1" cellspacing="0" cellpadding="5" width="100%" align="center">

    <tr height="40" bgcolor="darkseagreen">

        <td width="7%">记录编号:</td>

        <td width="10%">记录编号:</td>

        <td width="9%">记录编号:</td>

        <td width="7%">记录编号:</td>

        <td width="20%">记录编号:</td>

        <td width="7%">记录编号:</td>

        <td width="15%">记录编号:</td>

        <td width="15%">记录编号:</td>

        <td width="10%">记录编号:</td>

        <td width="10%">记录编号:</td>

    </tr>

    &test_result

</table>

</body>

</html>

 打开模版,数据替换

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

'''

Created on Aug 8, 2019

@author: liliang

'''

import os

import time

from ctypes.test.test_pickling import name

class MyClass():

    '''

    classdocs

    '''

    def __init__(self):

        pass

    def open_file(self):

        tempfile=os.path.abspath("..")+"/demo/2.html"

        tem=open(tempfile, mode='r', encoding='utf-8').read()

        return tem

    def write_file(self,file,test_data,version,passnum,faillnum,errornum,lasttime,all_data):

        file=file.replace("&test_data",test_data)

        file=file.replace("&version",version)

        file=file.replace('&pass',passnum)

        file=file.replace('&fail',faillnum)

        file=file.replace('&error',errornum)

        file=file.replace('&lasttime',lasttime)

        content=''

        for in range(0,len(all_data)):

            if all_data[i]["name"=="粉丝":

                content+="<tr height=40 bgcolor='red'>"

                content+="<td width='7%%' >%s</d>" %str(all_data[i]["name"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["age"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["sex"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["school"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["work"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["address"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["sex1"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["school2"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["work3"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["address4"])

                content+="</tr>"

            else:

         

                content+="<tr height=40 bgcolor='bisque'>"

                content+="<td width='7%%' >%s</d>" %str(all_data[i]["name"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["age"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["sex"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["school"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["work"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["address"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["sex1"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["school2"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["work3"])

                content+="<td width='7%%'>%s</d>" %str(all_data[i]["address4"])

                content+="</tr>"

                 

#         for result in all_data:

#             content+="<tr height=40>"

#             content+="<td width='7%%'>%s</d>" %str(result[0])

#             content+="<td width='7%%'>%s</d>" %str(result[1])

#             content+="<td width='7%%'>%s</d>" %str(result[2])

#             content+="<td width='7%%'>%s</d>" %result[3]

#             content+="<td width='7%%'>%s</d>" %result[4]

#             content+="<td width='7%%'>%s</d>" %result[5]

#             content+="<td width='7%%'>%s</d>" %result[6]

#             content+="<td width='7%%'>%s</d>" %result[7]

#             content+="<td width='7%%'>%s</d>" %result[8]

#             content+="<td width='7%%'>%s</d>" %result[9]

#             content+="</tr>"

        file=file.replace('&test_result',content)

        file_folder=os.path.abspath("..")+"/demo/"

        file_name=file_folder+time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())+".html"

        report_file=open(file_name, mode="w+",  encoding='utf-8')

        report_file.write(file)

        report_file.close()

    def get_datetime(self):

        now_time=time.strftime("%Y_%M_%d_%H:%M:%S",time.localtime())

        return now_time

if __name__ == '__main__':

    my=MyClass()

    file=my.open_file()

    all_data=[

            {"name":"Tom","age":23,"sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学2","work3":"学生","address4":"上海"},

            {"name":"数据","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小3学","work3":"学生","address4":"上海"},

            {"name":"粉丝","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学4","work3":"学生","address4":"上海"},

            {"name":"阿道夫","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小fs学","work3":"学生","address4":"上海"},

            {"name":"二娃","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学fa","work3":"学生","address4":"上海"},

            {"name":"我确认","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学","work3":"学生","address4":"上海"},

            {"name":"特务","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学fa","work3":"学生","address4":"上海"},

            {"name":"突然","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学ddd","work3":"学生","address4":"上海"},

            {"name":"圈儿","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小asss学","work3":"学生","address4":"上海"},

            {"name":"让他","age":"13","sex":"男","school":"希望小学","work":"学生","address":"上海","sex1":"男","school2":"希望小学fdsaa","work3":"学生","address4":"上海"},

              ]

    my.write_file(file"2019_07_08_03:07:59""1.3.0""90""7""key error""2019_07_08_03:07:59", all_data)

        

1

 生成报告

工程目录

Python接口自动化测试零基础入门到精通(2023最新版)

相关文章:

python自动化测试模板

1:准备html模版 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 <!DOCTYPE html> <html> <head> <meta charset"utf-8"> <title>接口自动化…...

MySQL 外连接和内连接的查询优化怎么做?

目录 1. 表连接方式的分类和需要注意的细节 2. 表连接时底层做了什么事&#xff1f; 3. 左外连接优化方案 4. 内连接优化方案 1. 表连接方式的分类和需要注意的细节 多表连接查询&#xff0c;大体上可以分为内连接与外连接。 内连接的意思就是把两个表有关联的部分都取出…...

Web自动化测试 —— cookie复用

一、cookie简介 cookie是一些数据&#xff0c;存储于用户电脑的文本文件中 当web服务器想浏览器发送web页面时&#xff0c;在链接关闭后&#xff0c;服务端不会记录用户信息 二、为什么要使用Cookie自动化登录 复用浏览器仍然在每次用例开始都需要人为介入若用例需要经常执行&…...

Java自学第1课:安装JDK+Eclipse

1 引言 在学习前&#xff0c;我想说一句&#xff0c;那就是为什么要学习Java。 每个人的出发点都不同&#xff0c;对于做信息化的工程技术人员来说&#xff0c;java不懂&#xff0c;就没法干项目。 尽管有c和matlab等基础&#xff0c;但java看起来与这些语言都不太一样。 做…...

zabbix6.4监控centos

1、关闭防火墙 setenforce 0 #关闭SELinux sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config #设置永久关闭SELinux systemctl stop firewalld.service #关闭防火墙 systemctl disable firewalld.service …...

炫云客户端信用额度如何修改?

现在炫云新注册用户信用额度是100元&#xff0c;但是有人觉得信用额度太高了&#xff0c;想修改信用额度&#xff0c;不知道炫云的信用额度如何修改&#xff0c;今天就教大家如何修改炫云的信用额度。炫云的信用额度在炫云官网和客户端都可以修改。 我们先来看炫云官网如何修改…...

windows jar包文件默认打开方式设置

1、管理员权限打开“注册表编辑器”&#xff1b; 2、定位到计算机\HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts项下&#xff0c;找到.jar项&#xff0c;再选中UserChoice项&#xff0c;其中ProgId值为jarfile 3、定位到计算机\HKEY_CLAS…...

高并发和存储之间的关系是什么?

文章目录 &#x1f50a;博主介绍&#x1f916;博主的简介&#x1f4e5;博主的目标 &#x1f964;本文内容&#x1f34a; 一、高并发对存储的压力&#x1f34a; 二、存储的性能和可扩展性 &#x1f4e2;总结 &#x1f50a;博主介绍 &#x1f4d5;我是廖志伟&#xff0c;一名Java…...

Antv/G2 图表坐标轴文字过长时添加省略号

// 格式化文字&#xff0c;超过长度添加省略号chart.axis(city, {label: {formatter: (text) > {// 字符太长添加省略号return text.length > 5 ? ${text.slice(0, 5)}... : text;}}})完整 demo&#xff1a; <!DOCTYPE html> <html lang"en"> &l…...

pycharm更改远程服务器地址

一、问题描述 在运行一些项目时&#xff0c;我们常需要在pycharm中连接远程服务器&#xff0c;但万一远程服务器的ip发生了变化&#xff0c;该如何修改呢&#xff1f;我们在file-settings-python interpreter中找到远程服务器&#xff0c;但是发现ip是灰色的&#xff0c;没有办…...

海康监控摄像机和录像机接入LiveMedia GB28181平台实现远程调取监控视频

海康威视各种型号监控摄像头或硬盘录像机&#xff08;NVR/HVR&#xff09;接入LiveMedia GB28181平台配置过程都非常简单明了&#xff0c;但有些细节需要注意&#xff0c;避免走弯路。 1、基本要求 (1) 网络要求 总体来说&#xff0c;只要监控设备和GB28181平台的网络是连通…...

一文全览各种 ES 查询在 Java 中的实现

2 词条查询 所谓词条查询&#xff0c;也就是ES不会对查询条件进行分词处理&#xff0c;只有当词条和查询字符串完全匹配时&#xff0c;才会被查询到。 &#xfeff; 2.1 等值查询-term 等值查询&#xff0c;即筛选出一个字段等于特定值的所有记录。 &#xfeff; SQL&…...

Centralized Feature Pyramid for Object Detection解读

Centralized Feature Pyramid for Object Detection 问题 主流的特征金字塔集中于层间特征交互&#xff0c;而忽略了层内特征规则。尽管一些方法试图在注意力机制或视觉变换器的帮助下学习紧凑的层内特征表示&#xff0c;但它们忽略了对密集预测任务非常重要的被忽略的角点区…...

unity中meta文件GUID异常问题

错误信息&#xff1a; The .meta file Assets/Scripts/Editor/ConvertConfigToBinary/TxtConverter.cs.meta does not have a valid GUID and its corresponding Asset file will be ignored. If this file is not malformed, please add a GUID, or delete the .meta file and…...

【k8s】pod集群调度

调度约束 Kubernetes 是通过 List-Watch **** 的机制进行每个组件的协作&#xff0c;保持数据同步的&#xff0c;每个组件之间的设计实现了解耦。 用户是通过 kubectl 根据配置文件&#xff0c;向 APIServer 发送命令&#xff0c;在 Node 节点上面建立 Pod 和 Container。…...

MathType数学公式编辑器2024官方最新版

Mathtype是一款数学公式编辑器&#xff0c;它可以帮助我们在文档中插入各种复杂的数学公式&#xff0c;使得我们的文档更加专业、规范。在使用Mathtype工具时&#xff0c;我们可以采取以下几种方法&#xff1a; 1. 鼠标直接点击插入公式 打开Mathtype后&#xff0c;在需要插入公…...

Android照搬,可删

1private void initview() {myradioGroup (RadioGroup) this.findViewById(R.id.MainActivity_RadioGroup);//通过id找到UI中的单选按钮组 2res getResources();// 得到Resources对象&#xff0c;从而通过它获取存在系统的资源 icon_home_true res.getDrawable(R.mipmap.ic…...

2022最新版-李宏毅机器学习深度学习课程-P26 自注意力机制

一、应用情境 输入任意长度个向量进行处理。 从输入看 文字处理&#xff08;自然语言处理&#xff09; 将word表示为向量 one-hotword-embedding声音信号处理 每个时间窗口&#xff08;Window, 25ms&#xff09;视为帧&#xff08;Frame&#xff09;,视为向量图 每个节点视为…...

【Docker】Linux路由连接两个不同网段namespace,连接namespace与主机

如果两个namespace处于不同的子网中&#xff0c;那么就不能通过bridge进行连接了&#xff0c;而是需要通过路由器进行三层转发。然而Linux并未像提供虚拟网桥一样也提供一个虚拟路由器设备&#xff0c;原因是Linux自身就具备有路由器功能。 路由器的工作原理是这样的&#xff…...

C语言 DAY10 内存分配

1.引入 int nums[10] {0}; //对 int len 10; int nums[len] {0}; //错 是因为系统的内存分配原则导致的 2.概述 在系统运行时&#xff0c;系统为了更好的管理进程中的内存&#xff0c;所以将内存进行了分配,其分配的机制就称为内存分配 1.静态分配原则 1.特点 1、在程序…...

手游刚开服就被攻击怎么办?如何防御DDoS?

开服初期是手游最脆弱的阶段&#xff0c;极易成为DDoS攻击的目标。一旦遭遇攻击&#xff0c;可能导致服务器瘫痪、玩家流失&#xff0c;甚至造成巨大经济损失。本文为开发者提供一套简洁有效的应急与防御方案&#xff0c;帮助快速应对并构建长期防护体系。 一、遭遇攻击的紧急应…...

visual studio 2022更改主题为深色

visual studio 2022更改主题为深色 点击visual studio 上方的 工具-> 选项 在选项窗口中&#xff0c;选择 环境 -> 常规 &#xff0c;将其中的颜色主题改成深色 点击确定&#xff0c;更改完成...

【HTML-16】深入理解HTML中的块元素与行内元素

HTML元素根据其显示特性可以分为两大类&#xff1a;块元素(Block-level Elements)和行内元素(Inline Elements)。理解这两者的区别对于构建良好的网页布局至关重要。本文将全面解析这两种元素的特性、区别以及实际应用场景。 1. 块元素(Block-level Elements) 1.1 基本特性 …...

在WSL2的Ubuntu镜像中安装Docker

Docker官网链接: https://docs.docker.com/engine/install/ubuntu/ 1、运行以下命令卸载所有冲突的软件包&#xff1a; for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done2、设置Docker…...

稳定币的深度剖析与展望

一、引言 在当今数字化浪潮席卷全球的时代&#xff0c;加密货币作为一种新兴的金融现象&#xff0c;正以前所未有的速度改变着我们对传统货币和金融体系的认知。然而&#xff0c;加密货币市场的高度波动性却成为了其广泛应用和普及的一大障碍。在这样的背景下&#xff0c;稳定…...

HarmonyOS运动开发:如何用mpchart绘制运动配速图表

##鸿蒙核心技术##运动开发##Sensor Service Kit&#xff08;传感器服务&#xff09;# 前言 在运动类应用中&#xff0c;运动数据的可视化是提升用户体验的重要环节。通过直观的图表展示运动过程中的关键数据&#xff0c;如配速、距离、卡路里消耗等&#xff0c;用户可以更清晰…...

Fabric V2.5 通用溯源系统——增加图片上传与下载功能

fabric-trace项目在发布一年后,部署量已突破1000次,为支持更多场景,现新增支持图片信息上链,本文对图片上传、下载功能代码进行梳理,包含智能合约、后端、前端部分。 一、智能合约修改 为了增加图片信息上链溯源,需要对底层数据结构进行修改,在此对智能合约中的农产品数…...

基于 TAPD 进行项目管理

起因 自己写了个小工具&#xff0c;仓库用的Github。之前在用markdown进行需求管理&#xff0c;现在随着功能的增加&#xff0c;感觉有点难以管理了&#xff0c;所以用TAPD这个工具进行需求、Bug管理。 操作流程 注册 TAPD&#xff0c;需要提供一个企业名新建一个项目&#…...

【SSH疑难排查】轻松解决新版OpenSSH连接旧服务器的“no matching...“系列算法协商失败问题

【SSH疑难排查】轻松解决新版OpenSSH连接旧服务器的"no matching..."系列算法协商失败问题 摘要&#xff1a; 近期&#xff0c;在使用较新版本的OpenSSH客户端连接老旧SSH服务器时&#xff0c;会遇到 "no matching key exchange method found"​, "n…...

论文阅读笔记——Muffin: Testing Deep Learning Libraries via Neural Architecture Fuzzing

Muffin 论文 现有方法 CRADLE 和 LEMON&#xff0c;依赖模型推理阶段输出进行差分测试&#xff0c;但在训练阶段是不可行的&#xff0c;因为训练阶段直到最后才有固定输出&#xff0c;中间过程是不断变化的。API 库覆盖低&#xff0c;因为各个 API 都是在各种具体场景下使用。…...