From 3ed488dae2d19709c31f651da7e9cecb89c57d38 Mon Sep 17 00:00:00 2001 From: Julien Muchembled <jm@nexedi.com> Date: Fri, 18 Jun 2010 16:20:22 +0000 Subject: [PATCH] runUnitTest: make main process log to stderr if no test is specified git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@36455 20353a03-c40f-0410-a6d1-a30d3c3de9de --- product/ERP5Type/tests/runUnitTest.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/product/ERP5Type/tests/runUnitTest.py b/product/ERP5Type/tests/runUnitTest.py index 476bf2a6fa..0716adc141 100755 --- a/product/ERP5Type/tests/runUnitTest.py +++ b/product/ERP5Type/tests/runUnitTest.py @@ -396,14 +396,14 @@ def runUnitTestList(test_list, verbosity=1, debug=0): from Testing import ZopeTestCase # Zope 2.8: this will import custom_zodb.py OFS.Application.import_products = import_products + from ZConfig.components.logger import handlers, logger, loghandler + import logging + root_logger = logging.getLogger() try: # On Zope 2.8, ZopeTestCase does not have any logging facility. # So we must emulate the usual Zope startup code to catch log # messages. from ZConfig.matcher import SectionValue - from ZConfig.components.logger.handlers import FileHandlerFactory - from ZConfig.components.logger.logger import EventLogFactory - import logging section = SectionValue({'dateformat': '%Y-%m-%d %H:%M:%S', 'format': '%(asctime)s.%(msecs)03d %(levelname)s %(name)s %(message)s', 'level': logging.INFO, @@ -415,11 +415,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0): 'formatter': None, }, None, None) - section.handlers = [FileHandlerFactory(section)] - eventlog = EventLogFactory(section) - logger = logging.getLogger() - logger.handlers = [] - eventlog() + section.handlers = [handlers.FileHandlerFactory(section)] + root_logger.handlers = [] + logger.EventLogFactory(section)() except ImportError: pass @@ -537,6 +535,8 @@ def runUnitTestList(test_list, verbosity=1, debug=0): if zeo_client_pid_list is None: result = suite() else: + if not test_list: + root_logger.handlers.append(loghandler.StreamHandler(sys.stderr)) _print('done (%.3fs)' % (time.time() - _start)) result = TestRunner(verbosity=verbosity).run(suite) finally: -- 2.30.9