httprunner 造数据

 

from faker import Faker

f = Faker(locale='zh_CN')
def getWords(name=None):
    '''
    获取随机汉字
    :param name:
    :return:
    '''
    worlds = f.word() + f.word()
    if name:
        worlds = name + '_' + worlds
    return worlds

def getStr(name=None):
    '''
    获取随机字符串
    :param name:
    :return:
    '''
    worlds = f.pystr()
    if name:
        worlds = name + '_' + worlds
    return worlds

def getLenStr(name):
    '''
    返回字符串长度
    :param name:
    :return:
    '''
    return len(name)

# 参考 https://www.jianshu.com/p/6bd6869631d9

 

posted on 2020-07-27 15:10  蜗牛也是妞  阅读(255)  评论(0编辑  收藏  举报