diff options
author | Cheryl Sabella <cheryl.sabella@gmail.com> | 2018-09-25 23:00:08 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2018-09-25 23:00:08 (GMT) |
commit | d345bb4d9b6e16c681cd8a4e1fff94ecd6b0bb09 (patch) | |
tree | 270c58e201787cd118f29c2650cd6dfa605f27e3 /Lib/test | |
parent | fad6af2744c0b022568f7f4a8afc93fed056d4db (diff) | |
download | cpython-d345bb4d9b6e16c681cd8a4e1fff94ecd6b0bb09.zip cpython-d345bb4d9b6e16c681cd8a4e1fff94ecd6b0bb09.tar.gz cpython-d345bb4d9b6e16c681cd8a4e1fff94ecd6b0bb09.tar.bz2 |
bpo-34334: Don't log traceback twice in QueueHandler (GH-9537)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_logging.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index b9dad64..d352e5f 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -3345,6 +3345,21 @@ class QueueHandlerTest(BaseTest): 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')) + handler.close() + + @unittest.skipUnless(hasattr(logging.handlers, 'QueueListener'), + 'logging.handlers.QueueListener required for this test') + def test_queue_listener_with_StreamHandler(self): + # Test that traceback only appends once (bpo-34334). + listener = logging.handlers.QueueListener(self.queue, self.root_hdlr) + listener.start() + try: + 1 / 0 + except ZeroDivisionError as e: + exc = e + self.que_logger.exception(self.next_message(), exc_info=exc) + listener.stop() + self.assertEqual(self.stream.getvalue().strip().count('Traceback'), 1) if hasattr(logging.handlers, 'QueueListener'): import multiprocessing |