diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-02-25 22:45:25 +0000 |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2011-02-25 22:45:25 +0000 |
commit | fc1cf41911fcb91da0802ebc4e49e7f342f59e21 (patch) | |
tree | 4753f74d6e6f7d8ccc30a915106f037550588938 | |
parent | 95bcb93041417efb7166fc1715c1f9db66a54d81 (diff) | |
download | cpython-git-fc1cf41911fcb91da0802ebc4e49e7f342f59e21.tar.gz |
test_logging: Added more diagnostics for buildbot failures.
-rw-r--r-- | Lib/test/test_logging.py | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 5dd59a4239..f9488ce537 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -2046,11 +2046,40 @@ for when, exp in (('S', 1), ('D', 60 * 60 * 24), ('MIDNIGHT', 60 * 60 * 23), # current time (epoch start) is a Thursday, W0 means Monday - ('W0', secs(days=4, hours=23)),): + ('W0', secs(days=4, hours=23)), + ): def test_compute_rollover(self, when=when, exp=exp): rh = logging.handlers.TimedRotatingFileHandler( self.fn, when=when, interval=1, backupCount=0) - self.assertEqual(exp, rh.computeRollover(0.0)) + currentTime = 0.0 + actual = rh.computeRollover(currentTime) + if exp != actual: + # Failures occur on some systems for MIDNIGHT and W0. + # Print detailed calculation for MIDNIGHT so we can try to see + # what's going on + if when == 'MIDNIGHT': + try: + if rh.utc: + t = time.gmtime(currentTime) + else: + t = time.localtime(currentTime) + currentHour = t[3] + currentMinute = t[4] + currentSecond = t[5] + # r is the number of seconds left between now and midnight + r = logging.handlers._MIDNIGHT - ((currentHour * 60 + + currentMinute) * 60 + + currentSecond) + result = currentTime + r + print('t: %s (%s)' % (t, rh.utc), file=sys.stderr) + print('currentHour: %s' % currentHour, file=sys.stderr) + print('currentMinute: %s' % currentMinute, file=sys.stderr) + print('currentSecond: %s' % currentSecond, file=sys.stderr) + print('r: %s' % r, file=sys.stderr) + print('result: %s' % result, file=sys.stderr) + except Exception: + print('exception in diagnostic code: %s' % sys.exc_info()[1], file=sys.stderr) + self.assertEqual(exp, actual) rh.close() setattr(TimedRotatingFileHandlerTest, "test_compute_rollover_%s" % when, test_compute_rollover) |