- Timestamp:
- Jan 28, 2017 10:16:08 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/webui/wuireport.py
r65499 r65500 117 117 return (sTitle, sReport); 118 118 119 @staticmethod 120 def fmtPct(cHits, cTotal): 121 """ 122 Formats a percent number. 123 Returns a string. 124 """ 125 uPct = cHits * 100 / cTotal; 126 if uPct >= 10: 127 return '%s%%' % (uPct,); 128 return '%.1f%%' % (cHits * 100.0 / cTotal,); 129 130 @staticmethod 131 def fmtPctWithTotal(cHits, cTotal): 132 """ 133 Formats a percent number with total in parentheses. 134 Returns a string. 135 """ 136 return '%s (%s)' % (WuiReportBase.fmtPct(cHits, cTotal), cTotal); 137 138 @staticmethod 139 def fmtPctWithHitsAndTotal(cHits, cTotal): 140 """ 141 Formats a percent number with total in parentheses. 142 Returns a string. 143 """ 144 return '%s (%s/%s)' % (WuiReportBase.fmtPct(cHits, cTotal), cHits, cTotal); 145 146 119 147 120 148 class WuiReportSuccessRate(WuiReportBase): … … 138 166 sPeriod = self._oModel.getPeriodDesc(i); 139 167 if cTotal > 0: 140 iPctSuccess = dStatuses[ReportModelBase.ksTestStatus_Success] * 100 / cTotal;141 iPctSkipped = dStatuses[ReportModelBase.ksTestStatus_Skipped] * 100 / cTotal;142 iPctFailure = dStatuses[ReportModelBase.ksTestStatus_Failure] * 100 / cTotal;143 oTable.addRow(sPeriod, [ iPctSuccess, iPctSkipped, iPctFailure],144 [ '%s%% (%d)' % (iPctSuccess, dStatuses[ReportModelBase.ksTestStatus_Success]),145 '%s%% (%d)' % (iPctSkipped, dStatuses[ReportModelBase.ksTestStatus_Skipped]),146 '%s%% (%d)' % (iPctFailure, dStatuses[ReportModelBase.ksTestStatus_Failure]), ]);168 oTable.addRow(sPeriod, 169 [ dStatuses[ReportModelBase.ksTestStatus_Success] * 100 / cTotal, 170 dStatuses[ReportModelBase.ksTestStatus_Skipped] * 100 / cTotal, 171 dStatuses[ReportModelBase.ksTestStatus_Failure] * 100 / cTotal, ], 172 [ self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Success], cTotal), 173 self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Skipped], cTotal), 174 self.fmtPctWithTotal(dStatuses[ReportModelBase.ksTestStatus_Failure], cTotal), ]); 147 175 else: 148 176 oTable.addRow(sPeriod, [ 0, 0, 0 ], [ '0%', '0%', '0%' ]); … … 380 408 oRow = oPeriod.dRowsById.get(idKey, None); 381 409 if oRow is not None: 382 uPct = oRow.cHits * 100 / oRow.cTotal; 383 aiValues.append(uPct); 384 if uPct >= 10: 385 asValues.append('%u%% (%u/%u)' % (uPct, oRow.cHits, oRow.cTotal)); 386 else: 387 asValues.append('%.1f%% (%u/%u)' % (oRow.cHits * 100.0 / oRow.cTotal, oRow.cHits, oRow.cTotal)); 410 aiValues.append(oRow.cHits * 100 / oRow.cTotal); 411 asValues.append(self.fmtPctWithHitsAndTotal(oRow.cHits, oRow.cTotal)); 388 412 else: 389 413 aiValues.append(0); … … 398 422 uPct = oSet.dcHitsPerId[idKey] * 100 / oSet.dcTotalPerId[idKey]; 399 423 aiValues.append(uPct); 400 if uPct >= 10: 401 asValues.append('%u%% (%u/%u)' % (uPct, oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey])); 402 else: 403 asValues.append('%.1f%% (%u/%u)' % ( oSet.dcHitsPerId[idKey] * 100.0 / oSet.dcTotalPerId[idKey], 404 oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey],)); 424 asValues.append(self.fmtPctWithHitsAndTotal(oSet.dcHitsPerId[idKey], oSet.dcTotalPerId[idKey])); 405 425 oTable.addRow('Totals', aiValues, asValues); 406 426
Note:
See TracChangeset
for help on using the changeset viewer.