测试开发: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和OpenCV库实现实时颜色识别系统

《使用Python和OpenCV库实现实时颜色识别系统》:本文主要介绍使用Python和OpenCV库实现的实时颜色识别系统,这个系统能够通过摄像头捕捉视频流,并在视频中指定区域内识别主要颜色(红... 目录一、引言二、系统概述三、代码解析1. 导入库2. 颜色识别函数3. 主程序循环四、HSV色彩空间详解

SQLite3命令行工具最佳实践指南

《SQLite3命令行工具最佳实践指南》SQLite3是轻量级嵌入式数据库,无需服务器支持,具备ACID事务与跨平台特性,适用于小型项目和学习,sqlite3.exe作为命令行工具,支持SQL执行、数... 目录1. SQLite3简介和特点2. sqlite3.exe使用概述2.1 sqlite3.exe

一文深入详解Python的secrets模块

《一文深入详解Python的secrets模块》在构建涉及用户身份认证、权限管理、加密通信等系统时,开发者最不能忽视的一个问题就是“安全性”,Python在3.6版本中引入了专门面向安全用途的secr... 目录引言一、背景与动机:为什么需要 secrets 模块?二、secrets 模块的核心功能1. 基

一文详解MySQL如何设置自动备份任务

《一文详解MySQL如何设置自动备份任务》设置自动备份任务可以确保你的数据库定期备份,防止数据丢失,下面我们就来详细介绍一下如何使用Bash脚本和Cron任务在Linux系统上设置MySQL数据库的自... 目录1. 编写备份脚本1.1 创建并编辑备份脚本1.2 给予脚本执行权限2. 设置 Cron 任务2

python常见环境管理工具超全解析

《python常见环境管理工具超全解析》在Python开发中,管理多个项目及其依赖项通常是一个挑战,下面:本文主要介绍python常见环境管理工具的相关资料,文中通过代码介绍的非常详细,需要的朋友... 目录1. conda2. pip3. uvuv 工具自动创建和管理环境的特点4. setup.py5.

Python常用命令提示符使用方法详解

《Python常用命令提示符使用方法详解》在学习python的过程中,我们需要用到命令提示符(CMD)进行环境的配置,:本文主要介绍Python常用命令提示符使用方法的相关资料,文中通过代码介绍的... 目录一、python环境基础命令【Windows】1、检查Python是否安装2、 查看Python的安

Python UV安装、升级、卸载详细步骤记录

《PythonUV安装、升级、卸载详细步骤记录》:本文主要介绍PythonUV安装、升级、卸载的详细步骤,uv是Astral推出的下一代Python包与项目管理器,主打单一可执行文件、极致性能... 目录安装检查升级设置自动补全卸载UV 命令总结 官方文档详见:https://docs.astral.sh/

Python并行处理实战之如何使用ProcessPoolExecutor加速计算

《Python并行处理实战之如何使用ProcessPoolExecutor加速计算》Python提供了多种并行处理的方式,其中concurrent.futures模块的ProcessPoolExecu... 目录简介完整代码示例代码解释1. 导入必要的模块2. 定义处理函数3. 主函数4. 生成数字列表5.

Python中help()和dir()函数的使用

《Python中help()和dir()函数的使用》我们经常需要查看某个对象(如模块、类、函数等)的属性和方法,Python提供了两个内置函数help()和dir(),它们可以帮助我们快速了解代... 目录1. 引言2. help() 函数2.1 作用2.2 使用方法2.3 示例(1) 查看内置函数的帮助(

Python虚拟环境与Conda使用指南分享

《Python虚拟环境与Conda使用指南分享》:本文主要介绍Python虚拟环境与Conda使用指南,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、python 虚拟环境概述1.1 什么是虚拟环境1.2 为什么需要虚拟环境二、Python 内置的虚拟环境工具