summaryrefslogtreecommitdiff
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorl0rb <lorbritzer@yahoo.de>2019-11-06 22:21:40 +0100
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2019-11-06 21:21:40 +0000
commit519cb8772a9745b1c7d8218cabcd2f96ceda4d62 (patch)
treeedd2f5254bd9092e5216e33c69d9b2e57ff3d7c0 /Lib/test/test_logging.py
parent5c0c325453a175350e3c18ebb10cc10c37f9595c (diff)
downloadcpython-git-519cb8772a9745b1c7d8218cabcd2f96ceda4d62.tar.gz
bpo-38716: stop rotating handlers from setting inherited namer and rotator to None (GH-17072)
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 53b5bfc93f..6de8803081 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -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):