From 814d02dcd1b30a98f9a34c710be35de6db82aa40 Mon Sep 17 00:00:00 2001 From: Jesse Noller Date: Sat, 21 Nov 2009 14:38:23 +0000 Subject: [PATCH] issue6615: Additional test for logging support in multiprocessing --- Lib/test/test_multiprocessing.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Lib/test/test_multiprocessing.py b/Lib/test/test_multiprocessing.py index b16629b69ad..07d7a022cfd 100644 --- a/Lib/test/test_multiprocessing.py +++ b/Lib/test/test_multiprocessing.py @@ -1722,6 +1722,26 @@ class _TestLogging(BaseTestCase): root_logger.setLevel(root_level) logger.setLevel(level=LOG_LEVEL) + +class _TestLoggingProcessName(BaseTestCase): + + def handle(self, record): + assert record.processName == multiprocessing.current_process().name + self.__handled = True + + def test_logging(self): + handler = logging.Handler() + handler.handle = self.handle + self.__handled = False + # Bypass getLogger() and side-effects + logger = logging.getLoggerClass()( + 'multiprocessing.test.TestLoggingProcessName') + logger.addHandler(handler) + logger.propagate = False + + logger.warn('foo') + assert self.__handled + # # Test to verify handle verification, see issue 3321 #