MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_max_bytes

Method test_max_bytes

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

Source from the content-addressed store, hash-verified

6273 rh.close()
6274
6275 def test_max_bytes(self, delay=False):
6276 kwargs = {'delay': delay} if delay else {}
6277 os.unlink(self.fn)
6278 rh = logging.handlers.RotatingFileHandler(
6279 self.fn, encoding="utf-8", backupCount=2, maxBytes=100, **kwargs)
6280 self.assertIs(os.path.exists(self.fn), not delay)
6281 small = logging.makeLogRecord({'msg': 'a'})
6282 large = logging.makeLogRecord({'msg': 'b'*100})
6283 self.assertFalse(rh.shouldRollover(small))
6284 self.assertFalse(rh.shouldRollover(large))
6285 rh.emit(small)
6286 self.assertLogFile(self.fn)
6287 self.assertFalse(os.path.exists(self.fn + ".1"))
6288 self.assertFalse(rh.shouldRollover(small))
6289 self.assertTrue(rh.shouldRollover(large))
6290 rh.emit(large)
6291 self.assertTrue(os.path.exists(self.fn))
6292 self.assertLogFile(self.fn + ".1")
6293 self.assertFalse(os.path.exists(self.fn + ".2"))
6294 self.assertTrue(rh.shouldRollover(small))
6295 self.assertTrue(rh.shouldRollover(large))
6296 rh.close()
6297
6298 def test_max_bytes_delay(self):
6299 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