MCPcopy Index your code
hub / github.com/python/cpython / test_max_bytes

Method test_max_bytes

Lib/test/test_logging.py:6443–6464  ·  view source on GitHub ↗
(self, delay=False)

Source from the content-addressed store, hash-verified

6441 rh.close()
6442
6443 def test_max_bytes(self, delay=False):
6444 kwargs = {'delay': delay} if delay else {}
6445 os.unlink(self.fn)
6446 rh = logging.handlers.RotatingFileHandler(
6447 self.fn, encoding="utf-8", backupCount=2, maxBytes=100, **kwargs)
6448 self.assertIs(os.path.exists(self.fn), not delay)
6449 small = logging.makeLogRecord({'msg': 'a'})
6450 large = logging.makeLogRecord({'msg': 'b'*100})
6451 self.assertFalse(rh.shouldRollover(small))
6452 self.assertFalse(rh.shouldRollover(large))
6453 rh.emit(small)
6454 self.assertLogFile(self.fn)
6455 self.assertFalse(os.path.exists(self.fn + ".1"))
6456 self.assertFalse(rh.shouldRollover(small))
6457 self.assertTrue(rh.shouldRollover(large))
6458 rh.emit(large)
6459 self.assertTrue(os.path.exists(self.fn))
6460 self.assertLogFile(self.fn + ".1")
6461 self.assertFalse(os.path.exists(self.fn + ".2"))
6462 self.assertTrue(rh.shouldRollover(small))
6463 self.assertTrue(rh.shouldRollover(large))
6464 rh.close()
6465
6466 def test_max_bytes_delay(self):
6467 self.test_max_bytes(delay=True)

Callers 1

test_max_bytes_delayMethod · 0.95

Calls 9

shouldRolloverMethod · 0.95
assertFalseMethod · 0.80
assertLogFileMethod · 0.80
assertTrueMethod · 0.80
unlinkMethod · 0.45
assertIsMethod · 0.45
existsMethod · 0.45
emitMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected