(self, when=when, interval=interval, exp=exp)
| 7233 | ): |
| 7234 | for interval in 1, 3: |
| 7235 | def test_compute_rollover(self, when=when, interval=interval, exp=exp): |
| 7236 | rh = logging.handlers.TimedRotatingFileHandler( |
| 7237 | self.fn, encoding="utf-8", when=when, interval=interval, backupCount=0, utc=True) |
| 7238 | currentTime = 0.0 |
| 7239 | actual = rh.computeRollover(currentTime) |
| 7240 | if when.startswith('W'): |
| 7241 | exp += secs(days=7*(interval-1)) |
| 7242 | else: |
| 7243 | exp *= interval |
| 7244 | if exp != actual: |
| 7245 | # Failures occur on some systems for MIDNIGHT and W0. |
| 7246 | # Print detailed calculation for MIDNIGHT so we can try to see |
| 7247 | # what's going on |
| 7248 | if when == 'MIDNIGHT': |
| 7249 | try: |
| 7250 | if rh.utc: |
| 7251 | t = time.gmtime(currentTime) |
| 7252 | else: |
| 7253 | t = time.localtime(currentTime) |
| 7254 | currentHour = t[3] |
| 7255 | currentMinute = t[4] |
| 7256 | currentSecond = t[5] |
| 7257 | # r is the number of seconds left between now and midnight |
| 7258 | r = logging.handlers._MIDNIGHT - ((currentHour * 60 + |
| 7259 | currentMinute) * 60 + |
| 7260 | currentSecond) |
| 7261 | result = currentTime + r |
| 7262 | print('t: %s (%s)' % (t, rh.utc), file=sys.stderr) |
| 7263 | print('currentHour: %s' % currentHour, file=sys.stderr) |
| 7264 | print('currentMinute: %s' % currentMinute, file=sys.stderr) |
| 7265 | print('currentSecond: %s' % currentSecond, file=sys.stderr) |
| 7266 | print('r: %s' % r, file=sys.stderr) |
| 7267 | print('result: %s' % result, file=sys.stderr) |
| 7268 | except Exception as e: |
| 7269 | print('exception in diagnostic code: %s' % e, file=sys.stderr) |
| 7270 | self.assertEqual(exp, actual) |
| 7271 | rh.close() |
| 7272 | name = "test_compute_rollover_%s" % when |
| 7273 | if interval > 1: |
| 7274 | name += "_interval" |
nothing calls this directly
no test coverage detected
searching dependent graphs…