~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/__init__.py

  • Committer: Andrew Starr-Bochicchio
  • Date: 2015-07-31 01:04:41 UTC
  • mto: This revision was merged to the branch mainline in revision 6606.
  • Revision ID: a.starr.b@gmail.com-20150731010441-3domwjjtnjijxlr2
Use hexlify() from binascii directly as paramiko removed hexify().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2013, 2015, 2016 Canonical Ltd
 
1
# Copyright (C) 2005-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
32
32
import errno
33
33
import itertools
34
34
import logging
35
 
import math
36
35
import os
37
36
import platform
38
37
import pprint
360
359
            return float(''.join(details['benchtime'].iter_bytes()))
361
360
        return getattr(testCase, "_benchtime", None)
362
361
 
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
 
 
372
362
    def _elapsedTestTimeString(self):
373
363
        """Return a time string for the overall time the current test has taken."""
374
364
        return self._formatTime(self._delta_to_float(
375
 
            self._now() - self._start_datetime, 3))
 
365
            self._now() - self._start_datetime))
376
366
 
377
367
    def _testTimeString(self, testCase):
378
368
        benchmark_time = self._extractBenchmarkTime(testCase)
1369
1359
            % (message,
1370
1360
               pprint.pformat(a), pprint.pformat(b)))
1371
1361
 
1372
 
    # FIXME: This is deprecated in unittest2 but plugins may still use it so we
1373
 
    # need a deprecation period for them -- vila 2016-02-01
1374
1362
    assertEquals = assertEqual
1375
1363
 
1376
1364
    def assertEqualDiff(self, a, b, message=None):
1379
1367
        This is intended for use with multi-line strings where it can
1380
1368
        be hard to find the differences by eye.
1381
1369
        """
1382
 
        # TODO: perhaps override assertEqual to call this for strings?
 
1370
        # TODO: perhaps override assertEquals to call this for strings?
1383
1371
        if a == b:
1384
1372
            return
1385
1373
        if message is None:
2052
2040
        if err:
2053
2041
            self.log('errors:\n%r', err)
2054
2042
        if retcode is not None:
2055
 
            self.assertEqual(retcode, result,
 
2043
            self.assertEquals(retcode, result,
2056
2044
                              message='Unexpected return code')
2057
2045
        return result, out, err
2058
2046