mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-38716: stop rotating handlers from setting inherited namer and rotator to None (GH-17072)
This commit is contained in:
parent
5c0c325453
commit
519cb8772a
3 changed files with 23 additions and 2 deletions
|
|
@ -5030,6 +5030,25 @@ class RotatingFileHandlerTest(BaseFileTest):
|
|||
self.assertFalse(os.path.exists(namer(self.fn + ".3")))
|
||||
rh.close()
|
||||
|
||||
def test_namer_rotator_inheritance(self):
|
||||
class HandlerWithNamerAndRotator(logging.handlers.RotatingFileHandler):
|
||||
def namer(self, name):
|
||||
return name + ".test"
|
||||
|
||||
def rotator(self, source, dest):
|
||||
if os.path.exists(source):
|
||||
os.rename(source, dest + ".rotated")
|
||||
|
||||
rh = HandlerWithNamerAndRotator(
|
||||
self.fn, backupCount=2, maxBytes=1)
|
||||
self.assertEqual(rh.namer(self.fn), self.fn + ".test")
|
||||
rh.emit(self.next_rec())
|
||||
self.assertLogFile(self.fn)
|
||||
rh.emit(self.next_rec())
|
||||
self.assertLogFile(rh.namer(self.fn + ".1") + ".rotated")
|
||||
self.assertFalse(os.path.exists(rh.namer(self.fn + ".1")))
|
||||
rh.close()
|
||||
|
||||
@support.requires_zlib
|
||||
def test_rotator(self):
|
||||
def namer(name):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue