Loading parse_test_results.py +2 −2 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ class TestOutputParser: excel_writer.write_test_entry(entry) # Write chart excel_writer.write_pie_chart() excel_writer.write_pie_chart_data() # And finally, save the work book excel_writer.save() Loading write_excel.py +32 −21 Original line number Diff line number Diff line Loading @@ -97,36 +97,47 @@ class ExcelWriter: """ chart_work_sheet = self.get_chart_work_sheet() # Format data from main work sheet and insert into charts sheet # Titles chart_work_sheet["A2"] = "PASS" chart_work_sheet["A3"] = "FAIL" #Data data = self.get_pass_fail_counts() chart_work_sheet.cell(row=2, column=2).value = data[0] chart_work_sheet.cell(row=3, column=2).value = data[1] # Get data from main work sheet last_row = self.get_last_row() data = Reference(self.work_sheet, min_col=3, max_col=3, min_row=2, max_row=last_row) data = Reference(chart_work_sheet, min_col=2, max_col=2, min_row=2, max_row=3) labels = Reference(chart_work_sheet, min_col=1, max_col=1, min_row=2, max_row=3) # Construct pie chart pie = PieChart() pie.add_data(data, titles_from_data=True) #pie.set_categories(labels) pie.add_data(data)#, titles_from_data=True) pie.set_categories(labels) pie.title = "PASS/FAIL Distribution" chart_work_sheet.add_chart(pie, "A1") chart_work_sheet.add_chart(pie, "E1") def write_pie_chart(self): def get_pass_fail_counts(self): """ Writes a pie chart showing PASS/FAIL stats. Writes the chart to a separate work sheet. Return PASS/FAIL stats as tuple (# of PASS, # of FAIL) """ chart_work_sheet = self.get_chart_work_sheet() # Get data from main work sheet last_row = self.get_last_row() data = Reference(self.work_sheet, min_col=3, max_col=3, min_row=2, max_row=last_row) # Construct pie chart pie = PieChart() pie.add_data(data, titles_from_data=True) #pie.set_categories(labels) pie.title = "PASS/FAIL Distribution" chart_work_sheet.add_chart(pie, "A1") pass_count = 0 fail_count = 0 for row in self.work_sheet.iter_rows(min_col=3, max_col=3, min_row=2, max_row=last_row - 1): for cell in row: if cell.value == "PASS": pass_count += 1 elif cell.value == "FAIL": fail_count += 1 else: print("ERROR: unknown value {}".format(cell.value)) return (pass_count, fail_count) def save(self): """ Loading Loading
parse_test_results.py +2 −2 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ class TestOutputParser: excel_writer.write_test_entry(entry) # Write chart excel_writer.write_pie_chart() excel_writer.write_pie_chart_data() # And finally, save the work book excel_writer.save() Loading
write_excel.py +32 −21 Original line number Diff line number Diff line Loading @@ -97,36 +97,47 @@ class ExcelWriter: """ chart_work_sheet = self.get_chart_work_sheet() # Format data from main work sheet and insert into charts sheet # Titles chart_work_sheet["A2"] = "PASS" chart_work_sheet["A3"] = "FAIL" #Data data = self.get_pass_fail_counts() chart_work_sheet.cell(row=2, column=2).value = data[0] chart_work_sheet.cell(row=3, column=2).value = data[1] # Get data from main work sheet last_row = self.get_last_row() data = Reference(self.work_sheet, min_col=3, max_col=3, min_row=2, max_row=last_row) data = Reference(chart_work_sheet, min_col=2, max_col=2, min_row=2, max_row=3) labels = Reference(chart_work_sheet, min_col=1, max_col=1, min_row=2, max_row=3) # Construct pie chart pie = PieChart() pie.add_data(data, titles_from_data=True) #pie.set_categories(labels) pie.add_data(data)#, titles_from_data=True) pie.set_categories(labels) pie.title = "PASS/FAIL Distribution" chart_work_sheet.add_chart(pie, "A1") chart_work_sheet.add_chart(pie, "E1") def write_pie_chart(self): def get_pass_fail_counts(self): """ Writes a pie chart showing PASS/FAIL stats. Writes the chart to a separate work sheet. Return PASS/FAIL stats as tuple (# of PASS, # of FAIL) """ chart_work_sheet = self.get_chart_work_sheet() # Get data from main work sheet last_row = self.get_last_row() data = Reference(self.work_sheet, min_col=3, max_col=3, min_row=2, max_row=last_row) # Construct pie chart pie = PieChart() pie.add_data(data, titles_from_data=True) #pie.set_categories(labels) pie.title = "PASS/FAIL Distribution" chart_work_sheet.add_chart(pie, "A1") pass_count = 0 fail_count = 0 for row in self.work_sheet.iter_rows(min_col=3, max_col=3, min_row=2, max_row=last_row - 1): for cell in row: if cell.value == "PASS": pass_count += 1 elif cell.value == "FAIL": fail_count += 1 else: print("ERROR: unknown value {}".format(cell.value)) return (pass_count, fail_count) def save(self): """ Loading