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
No related merge requests found
......@@ -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:
......
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