Merge lp:~jelmer/bzr/fix-float into lp:bzr

Proposed by Jelmer Vernooij on 2015-11-08
Status: Merged
Approved by: Vincent Ladeuil on 2015-12-17
Approved revision: 6608
Merged at revision: 6607
Proposed branch: lp:~jelmer/bzr/fix-float
Merge into: lp:bzr
Diff against target: 32 lines (+11/-1)
1 file modified
bzrlib/tests/__init__.py (+11/-1)
To merge this branch: bzr merge lp:~jelmer/bzr/fix-float
Reviewer Review Type Date Requested Status
Vincent Ladeuil 2015-11-08 Approve on 2015-12-17
Richard Wilbur 2015-11-08 Approve on 2015-11-13
Review via email: mp+276934@code.launchpad.net

Commit message

Inline testtools private method to fix an issue in xenial (the private implementation has changed in an backward incompatible way).

Description of the change

Copy in _delta_to_float() from testtools, rather than calling a private function that may change without notice.

To post a comment you must log in.
lp:~jelmer/bzr/fix-float updated on 2015-11-08
6608. By Jelmer Vernooij on 2015-11-08

Fix arguments.

Richard Wilbur (richard-wilbur) wrote :

Looks good Jelmer, thanks for removing a call of someone else's private function!
+1

review: Approve
Vincent Ladeuil (vila) wrote :

Damn, too bad I came here so late: https://bazaar.launchpad.net/~canonical-platform-qa/uci-tests/trunk/revision/179

So obviously +1 from me ;)

review: Approve
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/__init__.py'
2--- bzrlib/tests/__init__.py 2013-08-09 15:09:23 +0000
3+++ bzrlib/tests/__init__.py 2015-11-08 15:32:31 +0000
4@@ -32,6 +32,7 @@
5 import errno
6 import itertools
7 import logging
8+import math
9 import os
10 import platform
11 import pprint
12@@ -359,10 +360,19 @@
13 return float(''.join(details['benchtime'].iter_bytes()))
14 return getattr(testCase, "_benchtime", None)
15
16+ def _delta_to_float(self, a_timedelta, precision):
17+ # This calls ceiling to ensure that the most pessimistic view of time
18+ # taken is shown (rather than leaving it to the Python %f operator
19+ # to decide whether to round/floor/ceiling. This was added when we
20+ # had pyp3 test failures that suggest a floor was happening.
21+ shift = 10 ** precision
22+ return math.ceil((a_timedelta.days * 86400.0 + a_timedelta.seconds +
23+ a_timedelta.microseconds / 1000000.0) * shift) / shift
24+
25 def _elapsedTestTimeString(self):
26 """Return a time string for the overall time the current test has taken."""
27 return self._formatTime(self._delta_to_float(
28- self._now() - self._start_datetime))
29+ self._now() - self._start_datetime, 3))
30
31 def _testTimeString(self, testCase):
32 benchmark_time = self._extractBenchmarkTime(testCase)