2020-11-22 22:20:33 +08:00
|
|
|
|
#!/usr/bin/env/ python3
|
2020-08-03 16:15:03 +08:00
|
|
|
|
# -*- coding:utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
@project: apiAutoTest
|
|
|
|
|
@author: zy7y
|
|
|
|
|
@file: test_api.py
|
|
|
|
|
@ide: PyCharm
|
2020-11-22 22:20:33 +08:00
|
|
|
|
@time: 2020/11/22
|
|
|
|
|
@desc: 测试方法
|
2020-08-03 16:15:03 +08:00
|
|
|
|
"""
|
2020-12-16 11:01:31 +08:00
|
|
|
|
from .conftest import pytest
|
2020-11-22 22:20:33 +08:00
|
|
|
|
|
2021-04-19 13:03:55 +08:00
|
|
|
|
from api import BaseRequest
|
2020-11-19 00:49:26 +08:00
|
|
|
|
from tools.data_process import DataProcess
|
2020-08-03 16:15:03 +08:00
|
|
|
|
|
|
|
|
|
|
2020-12-16 11:01:31 +08:00
|
|
|
|
# https://www.cnblogs.com/shouhu/p/12392917.html
|
|
|
|
|
# reruns 重试次数 reruns_delay 次数之间的延时设置(单位:秒)
|
|
|
|
|
# 失败重跑,会影响总测试时长,如不需要 将 @pytest.mark.flaky(reruns=3, reruns_delay=5) 注释即可
|
|
|
|
|
# @pytest.mark.flaky(reruns=2, reruns_delay=1)
|
2021-01-19 18:55:59 +08:00
|
|
|
|
# def test_main(cases, get_db): # 使用数据库功能(包含sql查询,数据备份,数据恢复)
|
|
|
|
|
# # 此处的cases入参来自与 conftest.py 文件中 cases函数,与直接使用 @pytest.mark.parametrize
|
|
|
|
|
# # 有着差不多的效果
|
|
|
|
|
# # 发送请求
|
|
|
|
|
# response, expect, sql = BaseRequest.send_request(cases)
|
|
|
|
|
# # 执行sql
|
|
|
|
|
# DataProcess.handle_sql(sql, get_db)
|
|
|
|
|
# # 断言操作
|
|
|
|
|
# DataProcess.assert_result(response, expect)
|
|
|
|
|
|
|
|
|
|
def test_main(cases): # 不使用数据库功能
|
2020-12-16 11:01:31 +08:00
|
|
|
|
# 发送请求
|
|
|
|
|
response, expect, sql = BaseRequest.send_request(cases)
|
|
|
|
|
# 断言操作
|
|
|
|
|
DataProcess.assert_result(response, expect)
|