[Python-checkins] bpo-35726: Add test for QueueHandler with multiple handlers (GH-11659) (GH-13061)

Ned Deily webhook-mailer at python.org
Thu May 2 13:24:06 EDT 2019


https://github.com/python/cpython/commit/3f8f64ebf3ab05038ed0b5a4adc83d0a5e9fbb82
commit: 3f8f64ebf3ab05038ed0b5a4adc83d0a5e9fbb82
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Ned Deily <nad at python.org>
date: 2019-05-02T13:24:01-04:00
summary:

bpo-35726: Add test for QueueHandler with multiple handlers (GH-11659) (GH-13061)

(cherry picked from commit 2dad96013ca24abdc5ba5a369ea42d70ff02487a)

Co-authored-by: Xtreak <tir.karthi at gmail.com>

files:
M Lib/test/test_logging.py

diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 3b671ce2ab37..6c5cb81377b3 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -3361,6 +3361,19 @@ def test_queue_listener_with_StreamHandler(self):
         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



More information about the Python-checkins mailing list