Python API 自动化实战详解(纯代码)
2019/7/14 23:06:04
本文主要是介绍Python API 自动化实战详解(纯代码),对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
主要讲如何在公司利用Python 搞API自动化。
1.分层设计思路
dataPool :数据池层,里面有我们需要的各种数据,包括一些公共数据等
config :基础配置
tools : 工具层
common: 公共方法层
runCase :需要运行的测试用例
noRunCase :不需要运行的测试用例
testReport :这里存放生成的测试报告
2.编写common: 公共方法层
2.1 getTimestamp.py
我们在common文件夹下新建一个getTimestamp.py。
因为业务中需要用到时间戳,我们这里把时间戳转换成str类型
# -*- coding:utf-8 -*- # 因为业务中需要用到时间戳,我们这里把时间戳转换成str类型 import time def get_timestamp(): timestamp = time.time() return str(int(timestamp))
3.config :基础配置
3.1 数据库配置 query_local_db_data.yaml
在config下新建query_local_db_data.yaml ,来存放数据库配置。
#mydb1 database1: host: 11.11.1.1 port: 3306 user: testuser password: testpw #mydb2 database2: host: 22.22.2.2 port: 3306 user: testuser password: testpw
在query_local_db_data.yaml 文件下,我们填写了两个数据库的配置,这里的数据库配置我是瞎写的,你们需要写你们自己真实的数据库配置。
以上这篇Python API 自动化实战详解(纯代码)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持找一找教程网。
这篇关于Python API 自动化实战详解(纯代码)的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python