def __init__(self,ui_case = 0):
        if ui_case == 0:
            test_file = path.get_multi_platform(path.PATH + r'/conf/release.xmind')
        else:
            test_file = path.get_multi_platform(path.PATH + r'/conf/test.xmind')

        logger.info('test_file:'+test_file)
        w = xmind.load(test_file)
        s1=w.getPrimarySheet() # get the first sheet

        r1=s1.getRootTopic() # get the root topic of this sheet

        r1.getSubTopics()

        get_LSubTopics(r1)

        Tcase.caseCheckPoint = LSubTopics
        Tcase.caseCount = LSubTopics.__len__()
def pic_operate(case_name, is_update, size, drive):
    name = case_name
    pic_drive = drive
    pic_size = copy.deepcopy(size)
    pic_expect_path = path.get_multi_platform(PATH_PIC + "/pic/expect/%s.png"%name)
    pic_fact_path = path.get_multi_platform(PATH_PIC + "/pic/fact/%s.png"%name)
    result_path = path.get_multi_platform(PATH_PIC + "/result/%s.png"%name)
    pic_size[2] = pic_size[2] + pic_size[0]
    pic_size[3] = pic_size[3] + pic_size[1]
    logger.info("截图起点坐标: " + str(pic_size[0]) + "," + str(pic_size[1]) + " 截图终点坐标: " + str(pic_size[2]) + "," + str(pic_size[3]))
    global similar_rate


    if is_update == "Y":
        pic_drive.get_screenshot_as_file(pic_expect_path)
        Image.open(pic_expect_path).crop(pic_size).save(pic_expect_path)

        similar_rate = 100
    elif is_update == "N":
        pic_drive.get_screenshot_as_file(pic_fact_path)
        Image.open(pic_fact_path).crop(pic_size).save(pic_fact_path)
        pic0 = Image.open(pic_expect_path)
        pic1 = Image.open(pic_fact_path)
        pic_joint(pic0, pic1).save(result_path)

        if is_reCompare == 0:

            #上报图片所属用例
            if result.case_pic.has_key(exe_status.exe_case_title):
                result.case_pic[exe_status.exe_case_title] += name + ".png" + "|"
            else:
                result.case_pic[exe_status.exe_case_title] = name + ".png" + "|"

        similar_rate = histsimilar.calc_similar_by_path(pic_fact_path,pic_expect_path)*100

    return similar_rate
def res_save(res_dic):
    """
    输出测试报表
    @type res_dic:dict
    """
    PATH = path.get_multi_platform(path.PATH + '/result/result.txt')
    res = ""
    # res = res + "成功用例数:" + str(res_dic["p_count"]) + "  失败用例数:" + str(res_dic["f_count"]) + '\n' + '\n'
    # res += "失败用例列表: "

    f = open(PATH, 'w')

    for key in res_dic:

        if failed_path.has_key(key.encode('utf8')) is False:
            failed_path[key.encode('utf8')] = "无"
            t_path = failed_path[key.encode('utf8')]
        else:
            t_path = failed_path[key.encode('utf8')].encode('utf8')
            t_path = t_path[:-1]

        if case_pic.has_key(key.encode('utf8')) is False:
            case_pic[key.encode('utf8')] = ""
            t_pic = case_pic[key.encode('utf8')]
        else:
            t_pic = case_pic[key.encode('utf8')].encode('utf8')
            t_pic = t_pic[:-1]

        if case_purpose.has_key(key.encode('utf8')) is False:
            case_purpose[key.encode('utf8')] = "无"
            t_purpose = case_purpose[key.encode('utf8')]
        else:
            t_purpose = case_purpose[key.encode('utf8')].encode('utf8')

        res = res + str(key)
        res = res + ";" + t_purpose
        res = res + ";" + res_dic[key.encode('utf8')].encode('utf8')
        res = res + ";" + t_pic
        res = res + ";" + t_path + '\n'
    res = res[:-1]
    f.write(res)

    print res
    f.close()
Beispiel #4
0
# -*- coding: utf-8 -*-
import json
import path
# import logging
# import logging.config
# logging.config.fileConfig("log.conf")
# logger = logging.getLogger("log_NB")


#10.1.88.101
PATH = path.PATH
# file = PATH.replace('/',"\\") + r'\setting.txt'
file = path.get_multi_platform(PATH + r'/conf/setting.txt')
print file
f = open(file)
str = f.read()

file_map = json.loads(str)

if __name__ == '__main__':
    # logger.info("click log")

    print ""
    print ""
 def log_init(self):
     log_file = path.get_multi_platform(path.PATH + r'/conf/log.conf')
     logging.config.fileConfig(log_file)
     logger = logging.getLogger("log_NB")
     return logger