예제 #1
0
from common.report import get_now
import string
import datetime, time
from common.report import Report
import json
import re
from common.config import *
import random

pat = re.compile("DIS4=(.*?);")
log = Log().getLog()
pc = ParseConfig()
report = Report()  # 测试报告实例
server_database = get_base_info(pc.get_info("ServerDatabase"))

con_server = ConMysql(server_database)  # 服务器数据库链接
con = ConMysql()  # 本地数据库连接对象


def generate_random_str(randomlength=16):
    """
    生成一个指定长度的随机字符串
    :param randomlength: 指定长度,默认16
    :return:random_str str
    """
    random_str = ''
    base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789'
    length = len(base_str) - 1
    for i in range(randomlength):
        random_str += base_str[random.randint(0, length)]
    return random_str
예제 #2
0
파일: temp.py 프로젝트: ntghoney/api4
from common.report import get_now
import string
import datetime, time
from common.report import Report
import json
import re
from common.config import *
import random

pat = re.compile("DIS4=(.*?);")
log = Log().getLog()
pc = ParseConfig()
report = Report()  # 测试报告实例
server_database = get_base_info(pc.get_info("ServerDatabase"))

con_server = ConMysql(server_database)  # 服务器数据库链接
con = ConMysql()  # 本地数据库连接对象


def generate_random_str(randomlength=16):
    """
    生成一个指定长度的随机字符串
    """
    random_str = ''
    base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789'
    length = len(base_str) - 1
    for i in range(randomlength):
        random_str += base_str[random.randint(0, length)]
    return random_str

예제 #3
0
파일: newRun.py 프로젝트: ntghoney/api3
        environment = TESTDEV1
        database_info = get_base_info(pc.get_info("ServerDatabase1"))
    elif env == 2:
        environment = TESTDEV2
        database_info = get_base_info(pc.get_info("ServerDatabase2"))
    else:
        environment = TESTDEV2
        database_info = get_base_info(pc.get_info("ServerDatabase2"))
        log.error("参数错误,执行fp02环境")
    return environment, database_info


test_env, server_database = get_env()
print("当前执行环境-------{},数据库地址-------{}".format(test_env,
                                              server_database["host"]))
con_server = ConMysql(server_database)  # 服务器数据库链接
con = ConMysql()  # 本地数据库连接对象


def prepare_test_data(data):
    for key in data.keys():
        if key == "sql":
            try:
                con_server.execute_sql(data[key])
            except:
                log.error("sql语句出错:%s" % data[key])
        elif key == "sh":
            try:
                os.system(data[key])
            except:
                log.error("shell文件出错")