当前位置: 首页 > 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、在程序…...

docker详细操作--未完待续

docker介绍 docker官网: Docker&#xff1a;加速容器应用程序开发 harbor官网&#xff1a;Harbor - Harbor 中文 使用docker加速器: Docker镜像极速下载服务 - 毫秒镜像 是什么 Docker 是一种开源的容器化平台&#xff0c;用于将应用程序及其依赖项&#xff08;如库、运行时环…...

遍历 Map 类型集合的方法汇总

1 方法一 先用方法 keySet() 获取集合中的所有键。再通过 gey(key) 方法用对应键获取值 import java.util.HashMap; import java.util.Set;public class Test {public static void main(String[] args) {HashMap hashMap new HashMap();hashMap.put("语文",99);has…...

为什么需要建设工程项目管理?工程项目管理有哪些亮点功能?

在建筑行业&#xff0c;项目管理的重要性不言而喻。随着工程规模的扩大、技术复杂度的提升&#xff0c;传统的管理模式已经难以满足现代工程的需求。过去&#xff0c;许多企业依赖手工记录、口头沟通和分散的信息管理&#xff0c;导致效率低下、成本失控、风险频发。例如&#…...

【单片机期末】单片机系统设计

主要内容&#xff1a;系统状态机&#xff0c;系统时基&#xff0c;系统需求分析&#xff0c;系统构建&#xff0c;系统状态流图 一、题目要求 二、绘制系统状态流图 题目&#xff1a;根据上述描述绘制系统状态流图&#xff0c;注明状态转移条件及方向。 三、利用定时器产生时…...

论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)

笔记整理&#xff1a;刘治强&#xff0c;浙江大学硕士生&#xff0c;研究方向为知识图谱表示学习&#xff0c;大语言模型 论文链接&#xff1a;http://arxiv.org/abs/2407.16127 发表会议&#xff1a;ISWC 2024 1. 动机 传统的知识图谱补全&#xff08;KGC&#xff09;模型通过…...

css的定位(position)详解:相对定位 绝对定位 固定定位

在 CSS 中&#xff0c;元素的定位通过 position 属性控制&#xff0c;共有 5 种定位模式&#xff1a;static&#xff08;静态定位&#xff09;、relative&#xff08;相对定位&#xff09;、absolute&#xff08;绝对定位&#xff09;、fixed&#xff08;固定定位&#xff09;和…...

解决本地部署 SmolVLM2 大语言模型运行 flash-attn 报错

出现的问题 安装 flash-attn 会一直卡在 build 那一步或者运行报错 解决办法 是因为你安装的 flash-attn 版本没有对应上&#xff0c;所以报错&#xff0c;到 https://github.com/Dao-AILab/flash-attention/releases 下载对应版本&#xff0c;cu、torch、cp 的版本一定要对…...

【Zephyr 系列 10】实战项目:打造一个蓝牙传感器终端 + 网关系统(完整架构与全栈实现)

🧠关键词:Zephyr、BLE、终端、网关、广播、连接、传感器、数据采集、低功耗、系统集成 📌目标读者:希望基于 Zephyr 构建 BLE 系统架构、实现终端与网关协作、具备产品交付能力的开发者 📊篇幅字数:约 5200 字 ✨ 项目总览 在物联网实际项目中,**“终端 + 网关”**是…...

.Net Framework 4/C# 关键字(非常用,持续更新...)

一、is 关键字 is 关键字用于检查对象是否于给定类型兼容,如果兼容将返回 true,如果不兼容则返回 false,在进行类型转换前,可以先使用 is 关键字判断对象是否与指定类型兼容,如果兼容才进行转换,这样的转换是安全的。 例如有:首先创建一个字符串对象,然后将字符串对象隐…...

Vite中定义@软链接

在webpack中可以直接通过符号表示src路径&#xff0c;但是vite中默认不可以。 如何实现&#xff1a; vite中提供了resolve.alias&#xff1a;通过别名在指向一个具体的路径 在vite.config.js中 import { join } from pathexport default defineConfig({plugins: [vue()],//…...