(self, when=when, interval=interval, exp=exp)
| 7064 | ): |
| 7065 | for interval in 1, 3: |
| 7066 | def test_compute_rollover(self, when=when, interval=interval, exp=exp): |
| 7067 | rh = logging.handlers.TimedRotatingFileHandler( |
| 7068 | self.fn, encoding="utf-8", when=when, interval=interval, backupCount=0, utc=True) |
| 7069 | currentTime = 0.0 |
| 7070 | actual = rh.computeRollover(currentTime) |
| 7071 | if when.startswith('W'): |
| 7072 | exp += secs(days=7*(interval-1)) |
| 7073 | else: |
| 7074 | exp *= interval |
| 7075 | if exp != actual: |
| 7076 | # Failures occur on some systems for MIDNIGHT and W0. |
| 7077 | # Print detailed calculation for MIDNIGHT so we can try to see |
| 7078 | # what's going on |
| 7079 | if when == 'MIDNIGHT': |
| 7080 | try: |
| 7081 | if rh.utc: |
| 7082 | t = time.gmtime(currentTime) |
| 7083 | else: |
| 7084 | t = time.localtime(currentTime) |
| 7085 | currentHour = t[3] |
| 7086 | currentMinute = t[4] |
| 7087 | currentSecond = t[5] |
| 7088 | # r is the number of seconds left between now and midnight |
| 7089 | r = logging.handlers._MIDNIGHT - ((currentHour * 60 + |
| 7090 | currentMinute) * 60 + |
| 7091 | currentSecond) |
| 7092 | result = currentTime + r |
| 7093 | print('t: %s (%s)' % (t, rh.utc), file=sys.stderr) |
| 7094 | print('currentHour: %s' % currentHour, file=sys.stderr) |
| 7095 | print('currentMinute: %s' % currentMinute, file=sys.stderr) |
| 7096 | print('currentSecond: %s' % currentSecond, file=sys.stderr) |
| 7097 | print('r: %s' % r, file=sys.stderr) |
| 7098 | print('result: %s' % result, file=sys.stderr) |
| 7099 | except Exception as e: |
| 7100 | print('exception in diagnostic code: %s' % e, file=sys.stderr) |
| 7101 | self.assertEqual(exp, actual) |
| 7102 | rh.close() |
| 7103 | name = "test_compute_rollover_%s" % when |
| 7104 | if interval > 1: |
| 7105 | name += "_interval" |
nothing calls this directly
no test coverage detected