Skip to main content

Auto Create PyTest Frame and Fake Test Parameters For Red

Project description


通过解析IDL自动生成PyTest单测框架, 通过Faker库辅助生成部分参数, 并且支持单测参数和单测逻辑的向后兼容


    pip install pytest
    pip install pyaml
    pip install Faker==1.0.4
    pip install bson
    pip install dictdiffer


from auto_red_test import generate_red_test
from frame import ENV
from handler.stockage_handler import StockageHandler  # 需要单测的handler
import stockage_service.request.ttypes as test_request  # idl的request文件
import stockage_service.StockageService as test_service  # idl的service文件
root_path = ENV['root']  # 项目的根目录
# 第二个参数可以是handler列表但必须属于同一个service
generate_red_test(root_path, StockageHandler, test_service, test_request)
  • 自动生成的单测框架如下:
  • image


  • 第一次运行会生成request_config.yaml,可以自定义单测方法的参数,用于解决一个单测方法用到多个request的特殊情况, 格式如下:
# 配置单测参数
  request_A_name: request_A_obj_name
  request_B_name: request_A_obj_name
  request_B_name: request_B_obj_name
  request_C_name: request_C_obj_name

methodA为单测方法名, request_A_name为请求参数名,request_A_obj_name为请求参数对应的IDL Request名

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto-red-test-0.2.1.tar.gz (9.1 kB view hashes)

Uploaded source

Built Distribution

auto_red_test-0.2.1-py2.py3-none-any.whl (10.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page