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

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
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 Approve
Richard Wilbur Approve
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.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

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

review: Approve
Revision history for this message
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
Revision history for this message
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
=== modified file 'bzrlib/tests/__init__.py'
--- bzrlib/tests/__init__.py 2013-08-09 15:09:23 +0000
+++ bzrlib/tests/__init__.py 2015-11-08 15:32:31 +0000
@@ -32,6 +32,7 @@
32import errno32import errno
33import itertools33import itertools
34import logging34import logging
35import math
35import os36import os
36import platform37import platform
37import pprint38import pprint
@@ -359,10 +360,19 @@
359 return float(''.join(details['benchtime'].iter_bytes()))360 return float(''.join(details['benchtime'].iter_bytes()))
360 return getattr(testCase, "_benchtime", None)361 return getattr(testCase, "_benchtime", None)
361362
363 def _delta_to_float(self, a_timedelta, precision):
364 # This calls ceiling to ensure that the most pessimistic view of time
365 # taken is shown (rather than leaving it to the Python %f operator
366 # to decide whether to round/floor/ceiling. This was added when we
367 # had pyp3 test failures that suggest a floor was happening.
368 shift = 10 ** precision
369 return math.ceil((a_timedelta.days * 86400.0 + a_timedelta.seconds +
370 a_timedelta.microseconds / 1000000.0) * shift) / shift
371
362 def _elapsedTestTimeString(self):372 def _elapsedTestTimeString(self):
363 """Return a time string for the overall time the current test has taken."""373 """Return a time string for the overall time the current test has taken."""
364 return self._formatTime(self._delta_to_float(374 return self._formatTime(self._delta_to_float(
365 self._now() - self._start_datetime))375 self._now() - self._start_datetime, 3))
366376
367 def _testTimeString(self, testCase):377 def _testTimeString(self, testCase):
368 benchmark_time = self._extractBenchmarkTime(testCase)378 benchmark_time = self._extractBenchmarkTime(testCase)