summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2015-02-09 19:49:00 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2015-02-09 19:49:00 (GMT)
commit365701add94255d753d555c6b3833dd8cc6d43a0 (patch)
treeb4f6639641bfd98ca65bb73ef2227351d5c317ed /Lib/test/test_logging.py
parent438f9134cfb7a3b68cff9de9f730f42f68c2cc94 (diff)
downloadcpython-365701add94255d753d555c6b3833dd8cc6d43a0.zip
cpython-365701add94255d753d555c6b3833dd8cc6d43a0.tar.gz
cpython-365701add94255d753d555c6b3833dd8cc6d43a0.tar.bz2
Added respect_handler_level to QueueListener.
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 9674322..c8b6a98 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3006,6 +3006,25 @@ class QueueHandlerTest(BaseTest):
self.assertTrue(handler.matches(levelno=logging.WARNING, message='1'))
self.assertTrue(handler.matches(levelno=logging.ERROR, message='2'))
self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='3'))
+ handler.close()
+
+ # Now test with respect_handler_level set
+
+ handler = support.TestHandler(support.Matcher())
+ handler.setLevel(logging.CRITICAL)
+ listener = logging.handlers.QueueListener(self.queue, handler,
+ respect_handler_level=True)
+ listener.start()
+ try:
+ self.que_logger.warning(self.next_message())
+ self.que_logger.error(self.next_message())
+ self.que_logger.critical(self.next_message())
+ finally:
+ listener.stop()
+ self.assertFalse(handler.matches(levelno=logging.WARNING, message='4'))
+ self.assertFalse(handler.matches(levelno=logging.ERROR, message='5'))
+ self.assertTrue(handler.matches(levelno=logging.CRITICAL, message='6'))
+
ZERO = datetime.timedelta(0)