Exemplo n.º 1
0
    def write_result(self, result, message, test_duration):
        message = str(message)

        # write to: stdout
        print "\nTEST RESULT: {} {}".format(result, message)
        print "TEST DURATION: {}s".format(self.test_duration)

        # write to: log file
        orientations = [">", "^", ">", "^", "<"]
        box = Box(table_data=self._test_results, type="MINIMAL", col_orientations=orientations)
        summary = box.box_it()

        log_file = open(self._log_file, "w")
        log_file.write(summary + "\n\n")
        log_file.close()
Exemplo n.º 2
0
    def write_result_summary(self):

        box = Box(table_data=self.result_summary, type="SIMPLE_OUTLINE", header=False)

        # write to: stdout
        summary = box.box_it()
        self.print_log("SUMMARY RESULTS", "SUMMARY")
        print summary + "\n\n"

        # write to: log file
        # Note: we keep around the extra file til the last minute
        #       in case the script crashes, we still have current log
        summary = "\nTEST RESULT SUMMARY{}\n\n".format(summary)

        log_file_tmp = self._log_file.replace(".log", "_summary.log")
        log_file = open(log_file_tmp, "w")
        with open(self._log_file, "r") as myfile:
            test_data = myfile.read()

        log_file.write(summary)
        log_file.write(test_data)
        log_file.close()
        shutil.copy(log_file_tmp, self._log_file)
        os.remove(log_file_tmp)