Commit 3ed488da authored by Julien Muchembled's avatar Julien Muchembled

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
parent 47734529
...@@ -396,14 +396,14 @@ def runUnitTestList(test_list, verbosity=1, debug=0): ...@@ -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 from Testing import ZopeTestCase # Zope 2.8: this will import custom_zodb.py
OFS.Application.import_products = import_products OFS.Application.import_products = import_products
from ZConfig.components.logger import handlers, logger, loghandler
import logging
root_logger = logging.getLogger()
try: try:
# On Zope 2.8, ZopeTestCase does not have any logging facility. # On Zope 2.8, ZopeTestCase does not have any logging facility.
# So we must emulate the usual Zope startup code to catch log # So we must emulate the usual Zope startup code to catch log
# messages. # messages.
from ZConfig.matcher import SectionValue 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', section = SectionValue({'dateformat': '%Y-%m-%d %H:%M:%S',
'format': '%(asctime)s.%(msecs)03d %(levelname)s %(name)s %(message)s', 'format': '%(asctime)s.%(msecs)03d %(levelname)s %(name)s %(message)s',
'level': logging.INFO, 'level': logging.INFO,
...@@ -415,11 +415,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0): ...@@ -415,11 +415,9 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
'formatter': None, 'formatter': None,
}, },
None, None) None, None)
section.handlers = [FileHandlerFactory(section)] section.handlers = [handlers.FileHandlerFactory(section)]
eventlog = EventLogFactory(section) root_logger.handlers = []
logger = logging.getLogger() logger.EventLogFactory(section)()
logger.handlers = []
eventlog()
except ImportError: except ImportError:
pass pass
...@@ -537,6 +535,8 @@ def runUnitTestList(test_list, verbosity=1, debug=0): ...@@ -537,6 +535,8 @@ def runUnitTestList(test_list, verbosity=1, debug=0):
if zeo_client_pid_list is None: if zeo_client_pid_list is None:
result = suite() result = suite()
else: else:
if not test_list:
root_logger.handlers.append(loghandler.StreamHandler(sys.stderr))
_print('done (%.3fs)' % (time.time() - _start)) _print('done (%.3fs)' % (time.time() - _start))
result = TestRunner(verbosity=verbosity).run(suite) result = TestRunner(verbosity=verbosity).run(suite)
finally: finally:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment