swagger
Project description
生成pytest用例
install
python3 -m venv myenv
1. 初始化
Swagger2Tests --init --target='./'
初始化项目时会在指定的target
目录,初始化项目,并且生成一些基础文件。
- constants 可配置一些公共参数 比如 domain等
- helpers 一些通用方法
- templates 生成模板,可进行自定义修改
生成测试文件
Swagger2Tests --swagger='https://swagger.json' --target='./'
- swagger 参数支持文件和url
当前会按请求参数类型,一次性生成固定值,如果需要每次请求都动态更改,则可以在文件里进行修改,使用Helper类的方法
def test_chargingUsingPOST(self):
# 计算费用
requestBody = {
"appid": REQUEST_APPID,
"bizContent": {
'amount': Helper.get_random_float(),
'gasId': 'string',
'gunNo': Helper.get_random_int(),
'oilNo': Helper.get_random_int()
},
"sign": "string",
"timestamp": Helper.get_random_datetime()
}
用pytest 进行接口测试
python3 pytest_main.py
import pytest
if __name__ == '__main__':
pytest.main(['-s'])
- 使用pytest_main.py 执行的意义在于,避免有使用自定义包,因目录层级而存在的包导入问题
development
- test
python3 -m tests.test_run --swagger='./tests/oil_detail.json'
- compile and deploy
python3 setup.py sdist bdist_wheel
twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Swagger2Tests-1.1.1.tar.gz
(11.1 kB
view hashes)
Built Distribution
Close
Hashes for Swagger2Tests-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e3bdbf6f943f013234f37f084d83c2390fb5aeb757021a3fe7e20fd2057fe5 |
|
MD5 | a4d342bb29229b2ca86803b602ede3dc |
|
BLAKE2b-256 | fb1b05c25d8e108359c5ac471d086e1def9313bf6060198ac9f86318f617ab14 |