Merge lp:~zyga/checkbox/fix-1325898 into lp:checkbox

Proposed by Zygmunt Krynicki
Status: Merged
Approved by: Sylvain Pineau
Approved revision: 3050
Merged at revision: 3050
Proposed branch: lp:~zyga/checkbox/fix-1325898
Merge into: lp:checkbox
Diff against target: 54 lines (+14/-9)
1 file modified
plainbox/plainbox/impl/exporter/xlsx.py (+14/-9)
To merge this branch: bzr merge lp:~zyga/checkbox/fix-1325898
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Approve
Zygmunt Krynicki (community) Needs Fixing
Review via email: mp+221858@code.launchpad.net

Description of the change

55b5f29 plainbox:exporter:xlsx: fix division by zero

To post a comment you must log in.
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

actually, that's wrong

review: Needs Fixing
lp:~zyga/checkbox/fix-1325898 updated
3050. By Zygmunt Krynicki

plainbox:exporter:xlsx: fix division by zero

The xlsx exporter would crash if the total number of tests was zero so
let's handle that case.

https://bugs.launchpad.net/plainbox/+bug/1325898

Signed-off-by: Zygmunt Krynicki <email address hidden>

Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Thanks for the fix. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plainbox/plainbox/impl/exporter/xlsx.py'
2--- plainbox/plainbox/impl/exporter/xlsx.py 2014-05-28 14:42:26 +0000
3+++ plainbox/plainbox/impl/exporter/xlsx.py 2014-06-03 11:09:35 +0000
4@@ -336,6 +336,14 @@
5 )
6
7 def write_summary(self, data):
8+ if self.total != 0:
9+ pass_rate = "{:.2f}%".format(self.total_pass / self.total * 100)
10+ fail_rate = "{:.2f}%".format(self.total_fail / self.total * 100)
11+ skip_rate = "{:.2f}%".format(self.total_skip / self.total * 100)
12+ else:
13+ pass_rate = _("N/A")
14+ fail_rate = _("N/A")
15+ skip_rate = _("N/A")
16 self.worksheet2.set_column(0, 0, 5)
17 self.worksheet2.set_column(1, 1, 2)
18 self.worksheet2.set_column(3, 3, 27)
19@@ -346,9 +354,8 @@
20 ngettext('{} Test passed', '{} Tests passed',
21 self.total_pass).format(self.total_pass)
22 + " - "
23- + _('Success Rate: {:.2f}% ({}/{})').format(
24- self.total_pass / self.total * 100,
25- self.total_pass, self.total)
26+ + _('Success Rate: {} ({}/{})').format(
27+ pass_rate, self.total_pass, self.total)
28 ), self.format02)
29 self.worksheet2.write(5, 1, '✘', self.format11)
30 self.worksheet2.write(
31@@ -356,9 +363,8 @@
32 ngettext('{} Test failed', '{} Tests failed',
33 self.total_fail).format(self.total_fail)
34 + ' - '
35- + _('Failure Rate: {:.2f}% ({}/{})').format(
36- self.total_fail / self.total * 100,
37- self.total_fail, self.total)
38+ + _('Failure Rate: {} ({}/{})').format(
39+ fail_rate, self.total_fail, self.total)
40 ), self.format02)
41 self.worksheet2.write(6, 1, '-', self.format12)
42 self.worksheet2.write(
43@@ -366,9 +372,8 @@
44 ngettext('{} Test skipped', '{} Tests skipped',
45 self.total_skip).format(self.total_skip)
46 + ' - '
47- + _('Skip Rate: {:.2f}% ({}/{})').format(
48- self.total_skip / self.total * 100,
49- self.total_skip, self.total)
50+ + _('Skip Rate: {} ({}/{})').format(
51+ skip_rate, self.total_skip, self.total)
52 ), self.format02)
53 self.worksheet2.write_column(
54 'L3', [_('Fail'), _('Skip'), _('Pass')], self.format14)

Subscribers

People subscribed via source and target branches