summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXtreak <tir.karthi@gmail.com>2019-04-07 07:51:27 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2019-04-07 07:51:27 (GMT)
commit2dad96013ca24abdc5ba5a369ea42d70ff02487a (patch)
tree7a968ffea018a64f26a3cfc681952c338fa75f0c
parent89a894403cfa880d7f9d1d67070f61456d14cbde (diff)
downloadcpython-2dad96013ca24abdc5ba5a369ea42d70ff02487a.zip
cpython-2dad96013ca24abdc5ba5a369ea42d70ff02487a.tar.gz
cpython-2dad96013ca24abdc5ba5a369ea42d70ff02487a.tar.bz2
bpo-35726: Add test for QueueHandler with multiple handlers (GH-11659)
-rw-r--r--Lib/test/test_logging.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index b23ae24..1805249 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3505,6 +3505,19 @@ class QueueHandlerTest(BaseTest):
listener.stop()
self.assertEqual(self.stream.getvalue().strip().count('Traceback'), 1)
+ @unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'),
+ 'logging.handlers.QueueListener required for this test')
+ def test_queue_listener_with_multiple_handlers(self):
+ # Test that queue handler format doesn't affect other handler formats (bpo-35726).
+ self.que_hdlr.setFormatter(self.root_formatter)
+ self.que_logger.addHandler(self.root_hdlr)
+
+ listener = logging.handlers.QueueListener(self.queue, self.que_hdlr)
+ listener.start()
+ self.que_logger.error("error")
+ listener.stop()
+ self.assertEqual(self.stream.getvalue().strip(), "que -> ERROR: error")
+
if hasattr(logging.handlers, 'QueueListener'):
import multiprocessing
from unittest.mock import patch