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

(cherry picked from commit 2dad96013c)

Co-authored-by: Xtreak <tir.karthi@gmail.com>
This commit is contained in:
Miss Islington (bot) 2019-05-02 10:24:01 -07:00 committed by Ned Deily
parent 386b6f07a9
commit 3f8f64ebf3
1 changed files with 13 additions and 0 deletions

View File

@ -3361,6 +3361,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