def document_test(config_file, dict_result, data_result, **kwargs): """ Return a output a simple text """ stream = StandardDevice(sys.stdout) stream.write("\n" *15) for c_value in dict_result["tests"]["class_list"].itervalues(): stream.write("\n%s\n" % (c_value["name"])) stream.write("%s\n" % ("=" * len(c_value["name"]))) stream.write("%s\n" % ("".join([" %s\n" % line for line in \ c_value["description"] ]))) for m_value in c_value["methods"].itervalues(): stream.write(" %s\n" % (m_value["name"])) stream.write(" %s\n" % ("-" * len(m_value["name"]))) stream.write("%s\n" % ("".join([" %s\n" % line for line in \ m_value["description"] ])))
def simple_output(config_file, dict_result, data_result, **kwargs): """ Return a output a simple text """ stream = StandardDevice(sys.stdout) stream.write("Report of tests generate at %s\n\n" % datetime.now()) for c_value in dict_result["tests"]["class_list"].itervalues(): stream.write("\nClass: %s (Pass %s Failure %s Error %s)\n" % \ (c_value["name"], c_value["success_count"], \ c_value["failure_count"], c_value["error_count"])) stream.write("Pass\tFail\tError\tDuration\tMethods\n") for m_value in c_value["methods"].itervalues(): stream.write("%s\t%s\t%s\t%s\t%s\n" % \ (" X" if m_value["status"] == SUCCESS else " ", \ " X" if m_value["status"] == FAILURE else " ", \ " X" if m_value["status"] == ERROR else " ", \ m_value["stopped"] - m_value["started"], m_value["name"])) stream.write("\nDuration: %s" % \ (dict_result["stop_test"] - dict_result["start_test"])) stream.write("\nStatus: Tested %s - Pass %s Failure %s Error %s\n" % \ (dict_result["tests"]["success_count"] + dict_result["tests"]["error_count"] + \ dict_result["tests"]["failure_count"], dict_result["tests"]["success_count"], \ dict_result["tests"]["failure_count"], dict_result["tests"]["error_count"]))
def complete_output(config_file, dict_result, data_result, **kwargs): """ Return a output a simple text """ stream = StandardDevice(sys.stdout) stream.write("Report of tests generate at %s\n\n" % datetime.now()) stream.write("Label\n") stream.write("P - Pass\tF - Fail\t\tE - Error\n") stream.write("S - Skip\tEF - Expected Fail\tUS - Unexpected Success\n") for c_value in dict_result["tests"]["class_list"].itervalues(): stream.write("\nClass: %s (P:%s F:%s E:%s S:%s EF:%s US:%s)\n" % \ (c_value["name"], c_value["success_count"], \ c_value["failure_count"], c_value["error_count"], \ c_value["skip_count"], c_value["expected_failure_count"], \ c_value["unexpected_success_count"])) stream.write(" S\t F\t E\t S\tEF\tUS\tDuration\tMethods\n") for m_value in c_value["methods"].itervalues(): stream.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % \ (" X" if m_value["status"] == SUCCESS else " ", \ " X" if m_value["status"] == FAILURE else " ", \ " X" if m_value["status"] == ERROR else " ", \ " X" if m_value["status"] == SKIP else " ", \ " X" if m_value["status"] == EXPECTED_FAILURE else " ", \ " X" if m_value["status"] == UNEXPECTED_SUCCESS else " ", \ m_value["stopped"] - m_value["started"], m_value["name"])) stream.write("\nDuration: %s" % \ (dict_result["stop_test"] - dict_result["start_test"])) sum_all = dict_result["tests"]["success_count"] + dict_result["tests"]["error_count"] + \ dict_result["tests"]["failure_count"] + dict_result["tests"]["skip_count"] + \ dict_result["tests"]["expected_failure_count"] + \ dict_result["tests"]["unexpected_success_count"] stream.write("\nStatus: Tested %s - P:%s F:%s E:%s S:%s EF:%s US:%s\n" % \ (sum_all, dict_result["tests"]["success_count"], \ dict_result["tests"]["failure_count"], dict_result["tests"]["error_count"], \ dict_result["tests"]["skip_count"], dict_result["tests"]["expected_failure_count"], \ dict_result["tests"]["unexpected_success_count"]))
def show_help(*args, **kwargs): stream = StandardDevice(sys.stdout) stream.write("0 - Help (This information).\n") stream.write("1 - Simple test output with success, fail, error. \n") stream.write("2 - Complete test output with success, fail, error, skip, expected fail, unexpected success. \n")