测试开发:pyside2+python开发的自动生成测试数据小工具

2023-10-13 16:30

本文主要是介绍测试开发:pyside2+python开发的自动生成测试数据小工具,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

原来利用下班后的实践写了一个自动生成测试数据的小工具,使用的是python+tkinter写的,后来同事们提了几点优化意见,现已经python+pyside2编写完成。

git地址:https://github.com/yzxwp/test_tools_byPySide2

安装包下载:链接:  https://pan.baidu.com/s/10s6tQkl8LXNfN2A2TCd6mQ  提取码: y3fh

优化内容:

      1.优化了放大缩小。

     2.增加了中征码和5大行数据的生成。

 使用时需要注意两点:

1.message1.ui不能删除,要和exe文件放在一个文件夹UI中。

2.UI文件夹的名字不能够修改。

3.最好将exe发送桌面块面方式。

部分代码:

from PySide2.QtWidgets import QApplication, QMessageBox
from PySide2.QtUiTools import QUiLoader
from Method import get_name as name
from Method import get_phone as phone
from Method import get_idcard as idcard
from Method import get_scoure_card as scoure_card
from Method import get_car_vin as vi
from Method import get_zhongzhengma as zzm
from Method import get_bank_card as bankclass Stats():def __init__(self):try:self.ui = QUiLoader().load(r'./UI/message1.ui')except:self.ui = QUiLoader().load(r'../UI/message1.ui')self.ui.pushButton_all.clicked.connect(self.get_all)self.ui.pushButton_username.clicked.connect(self.get_name)self.ui.pushButton_phone.clicked.connect(self.get_phone)self.ui.pushButton_IDCard.clicked.connect(self.get_idcard)self.ui.pushButton_shtyzxm.clicked.connect(self.get_shtyzxm)self.ui.pushButton_zzjgdm.clicked.connect(self.get_zzjgdm)self.ui.pushButton_CJH.clicked.connect(self.get_cjh)self.ui.pushButton_zzm.clicked.connect(self.get_zzm)self.ui.pushButton_gonghang.clicked.connect(self.get_gonghang)self.ui.pushButton_nonghang.clicked.connect(self.get_nonghang)self.ui.pushButton_jiaohang.clicked.connect(self.get_jianhang)self.ui.pushButton_zhongguo.clicked.connect(self.get_zhongguo)self.ui.pushButton_jianshe.clicked.connect(self.get_jianshe)def get_all(self):self.ui.lineEdit_username.setText(name.random_name())print(name.random_name())self.ui.lineEdit_phone.setText(phone.phone_num())print(phone.phone_num())self.ui.lineEdit_IDCard.setText(idcard.ident_generator())print(idcard.ident_generator())self.ui.lineEdit_shtyzxm.setText(scoure_card.create_social_credit())print(scoure_card.create_social_credit())self.ui.lineEdit_zzjgdm.setText(scoure_card.create_organization())print(scoure_card.create_organization())self.ui.lineEdit_CJH.setText(vi.random_vin())print(vi.random_vin())self.ui.lineEdit_zzm.setText(zzm.ZZM())print(zzm.ZZM())self.ui.lineEdit_gonghang.setText(bank.gen_bank_card_gonghang())print(bank.gen_bank_card_gonghang())self.ui.lineEdit_nonghang.setText(bank.gen_bank_card_nonghang())print(bank.gen_bank_card_nonghang())self.ui.lineEdit_jiaohang.setText(bank.gen_bank_card_jiaotong())print(bank.gen_bank_card_jiaotong())self.ui.lineEdit_zhongguo.setText(bank.gen_bank_card_zhongguo())print(bank.gen_bank_card_zhongguo())self.ui.lineEdit_jianshe.setText(bank.gen_bank_card_jainshe())print(bank.gen_bank_card_jainshe())def get_name(self):self.ui.lineEdit_username.setText(name.random_name())print(name.random_name())def get_phone(self):self.ui.lineEdit_phone.setText(phone.phone_num())print(phone.phone_num())def get_idcard(self):self.ui.lineEdit_IDCard.setText(idcard.ident_generator())print(idcard.ident_generator())def get_shtyzxm(self):self.ui.lineEdit_shtyzxm.setText(scoure_card.create_social_credit())print(scoure_card.create_social_credit())def get_zzjgdm(self):self.ui.lineEdit_zzjgdm.setText(scoure_card.create_organization())print(scoure_card.create_organization())def get_cjh(self):self.ui.lineEdit_CJH.setText(vi.random_vin())print(vi.random_vin())def get_zzm(self):self.ui.lineEdit_zzm.setText(zzm.ZZM())print(zzm.ZZM())def get_gonghang(self):self.ui.lineEdit_gonghang.setText(bank.gen_bank_card_gonghang())print(bank.gen_bank_card_gonghang())def get_nonghang(self):self.ui.lineEdit_nonghang.setText(bank.gen_bank_card_nonghang())print(bank.gen_bank_card_nonghang())def get_jianhang(self):self.ui.lineEdit_jiaohang.setText(bank.gen_bank_card_jiaotong())print(bank.gen_bank_card_jiaotong())def get_zhongguo(self):self.ui.lineEdit_zhongguo.setText(bank.gen_bank_card_zhongguo())print(bank.gen_bank_card_zhongguo())def get_jianshe(self):self.ui.lineEdit_jianshe.setText(bank.gen_bank_card_jainshe())print(bank.gen_bank_card_jainshe())app = QApplication([])
stats = Stats()
stats.ui.show()
app.exec_()

后续优化:

1.利用python+flask+vue开发web应用。

2.增加自动生成monkey命令。

这篇关于测试开发:pyside2+python开发的自动生成测试数据小工具的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/204491

相关文章

Python的Darts库实现时间序列预测

《Python的Darts库实现时间序列预测》Darts一个集统计、机器学习与深度学习模型于一体的Python时间序列预测库,本文主要介绍了Python的Darts库实现时间序列预测,感兴趣的可以了解... 目录目录一、什么是 Darts?二、安装与基本配置安装 Darts导入基础模块三、时间序列数据结构与

Python正则表达式匹配和替换的操作指南

《Python正则表达式匹配和替换的操作指南》正则表达式是处理文本的强大工具,Python通过re模块提供了完整的正则表达式功能,本文将通过代码示例详细介绍Python中的正则匹配和替换操作,需要的朋... 目录基础语法导入re模块基本元字符常用匹配方法1. re.match() - 从字符串开头匹配2.

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

Python使用FastAPI实现大文件分片上传与断点续传功能

《Python使用FastAPI实现大文件分片上传与断点续传功能》大文件直传常遇到超时、网络抖动失败、失败后只能重传的问题,分片上传+断点续传可以把大文件拆成若干小块逐个上传,并在中断后从已完成分片继... 目录一、接口设计二、服务端实现(FastAPI)2.1 运行环境2.2 目录结构建议2.3 serv

通过Docker容器部署Python环境的全流程

《通过Docker容器部署Python环境的全流程》在现代化开发流程中,Docker因其轻量化、环境隔离和跨平台一致性的特性,已成为部署Python应用的标准工具,本文将详细演示如何通过Docker容... 目录引言一、docker与python的协同优势二、核心步骤详解三、进阶配置技巧四、生产环境最佳实践

Python一次性将指定版本所有包上传PyPI镜像解决方案

《Python一次性将指定版本所有包上传PyPI镜像解决方案》本文主要介绍了一个安全、完整、可离线部署的解决方案,用于一次性准备指定Python版本的所有包,然后导出到内网环境,感兴趣的小伙伴可以跟随... 目录为什么需要这个方案完整解决方案1. 项目目录结构2. 创建智能下载脚本3. 创建包清单生成脚本4

MyBatis Plus实现时间字段自动填充的完整方案

《MyBatisPlus实现时间字段自动填充的完整方案》在日常开发中,我们经常需要记录数据的创建时间和更新时间,传统的做法是在每次插入或更新操作时手动设置这些时间字段,这种方式不仅繁琐,还容易遗漏,... 目录前言解决目标技术栈实现步骤1. 实体类注解配置2. 创建元数据处理器3. 服务层代码优化填充机制详

Python实现Excel批量样式修改器(附完整代码)

《Python实现Excel批量样式修改器(附完整代码)》这篇文章主要为大家详细介绍了如何使用Python实现一个Excel批量样式修改器,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一... 目录前言功能特性核心功能界面特性系统要求安装说明使用指南基本操作流程高级功能技术实现核心技术栈关键函

python获取指定名字的程序的文件路径的两种方法

《python获取指定名字的程序的文件路径的两种方法》本文主要介绍了python获取指定名字的程序的文件路径的两种方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要... 最近在做项目,需要用到给定一个程序名字就可以自动获取到这个程序在Windows系统下的绝对路径,以下

Java使用Javassist动态生成HelloWorld类

《Java使用Javassist动态生成HelloWorld类》Javassist是一个非常强大的字节码操作和定义库,它允许开发者在运行时创建新的类或者修改现有的类,本文将简单介绍如何使用Javass... 目录1. Javassist简介2. 环境准备3. 动态生成HelloWorld类3.1 创建CtC