Exemplo n.º 1
0
def pytest_html_results_summary(prefix, summary, postfix):
    # Get configure content.
    prefix.extend([html.p("测试人: 测试组")])

    # Case number and time.
    case_count = summary[0].__str__()
    # count[0] The case number
    # count[1] The case when
    count = count_regx_compile.findall(case_count)[0]

    # Passed
    passed_str = summary[3].__str__()
    passed = result_regx_compile.findall(passed_str)[0].strip()

    # Failed
    failed_str = summary[9].__str__()
    failed = result_regx_compile.findall(failed_str)[0].strip()

    # Error
    error_str = summary[12].__str__()
    error = result_regx_compile.findall(error_str)[0].strip()

    #pass rate
    passed = int(passed.replace('passed', '').strip())
    failed = failed.replace('failed', '').strip()
    error = error.replace('errors', '').strip()
    # %
    passrate = str("%.2f%%" % (float(passed) / float(count[0]) * 100))

    file_path = os.path.join(gl.loadcasePath, 'result.txt')
    result_text = "; ".join([count[0], count[1], passed.__str__(), failed, error, passrate.__str__()])
    write_file(file_path, 'w', result_text)
Exemplo n.º 2
0
def _get_file_yaml(case_file):
    """
    Get file case YAML.
    """
    temp_list = []
    # Get the yaml file name and write to the queue.
    if case_file:
        # Specify the execution CASE.
        fargs = '&#'.join(case_file)
        temp_list.append(os.path.join(os.getcwd(), fargs))

        write_file(os.path.join(gl.loadcasePath, 'temp.cache'), 'w',
                   ';'.join(temp_list))
        return True
    return False
Exemplo n.º 3
0
def _get_dirs_case_yaml(case_dir):
    """
    Get dirs case YAML.
    """
    temp_list = []
    if case_dir:
        for root, dirs, files in os.walk(case_dir):
            for f in files:
                if 'yaml' in f:
                    d = os.path.join(os.getcwd(), case_dir)
                    temp_list.append(os.path.join(d, f))
        # 缓存目录
        cache_dir = os.path.join(gl.loadcasePath, ".am_cache")
        # Write file absolute path to file.
        write_file(os.path.join(cache_dir, 'yaml.cache'), 'w',
                   ';'.join(temp_list))
        return True
    return False