basic-auto-test/util/auto_test/api_test/custom_parameters.py

32 lines
893 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# -*- coding: utf-8 -*-
# -------------------------------
# @文件custom_parameters.py
# @时间2024/4/17 下午1:48
# @作者caiweichao
# @功能描述自定义参数配置接口上下游faker 数据
# -------------------------------
from util.basic.times import Times
from faker import Faker
faker = Faker(locale='zh_CN')
# 任何虚拟信息可以事先参考https://blog.csdn.net/weixin_43865008/article/details/115492280
custom_parameters = {
'now': Times.custom_time(model=" %Y-%m-%d %H:%M:%S"),
# 随机姓名
'faker_name': faker.name,
# 随机身份证号
'faker_ssn': faker.ssn,
# 随机职位
'faker_job': faker.job,
}
def call_back(match):
key = match.group(1)
if key in custom_parameters:
value = custom_parameters[key]
return value() if callable(value) else value
else:
return match.group(0)