avocado.core.output: Make stream logging to point to stdout

It is more natural [1] that output of --show-job-log goes to
stdout than stderr. Let's change that behavior and update
unittests accordingly.

[1] Natural in this sense is defined by the user's expectation -
    when setting avocado to --show-job-log, you expect that the
    job log *is* in the application's stdout.

Changes from v1:
 * Python 2.6 constructor param for StreamHandler is strm,
   that was changed in 2.7 to be stream. Let's keep compatibility
   by using positional arguments.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 bc597920
......@@ -117,7 +117,7 @@ def add_console_handler(logger):
:param logger: `logging.Logger` instance.
"""
console_handler = logging.StreamHandler()
console_handler = logging.StreamHandler(sys.stdout)
formatter = logging.Formatter(fmt='%(message)s')
console_handler.setFormatter(formatter)
logger.addHandler(console_handler)
......
......@@ -117,11 +117,11 @@ class MultiplexTests(unittest.TestCase):
for msg in ('A', 'ASDFASDF', 'This is very long\nmultiline\ntext.'):
msg = ('[stdout] Custom variable: ' +
'\n[stdout] '.join(msg.splitlines()))
self.assertIn(msg, result.stderr, "Multiplexed variable should "
self.assertIn(msg, result.stdout, "Multiplexed variable should "
"produce:"
"\n %s\nwhich is not present in the output:\n %s"
% ("\n ".join(msg.splitlines()),
"\n ".join(result.stderr.splitlines())))
"\n ".join(result.stdout.splitlines())))
if __name__ == '__main__':
unittest.main()
......@@ -57,7 +57,7 @@ class StandaloneTests(unittest.TestCase):
expected_rc = 1
result = self.run_and_check(cmd_line, expected_rc, 'failtest_nasty')
exc = "NastyException: Nasty-string-like-exception"
count = result.stderr.count("\n%s" % exc)
count = result.stdout.count("\n%s" % exc)
self.assertEqual(count, 2, "Exception \\n%s should be present twice in"
"the log (once from the log, second time when parsing"
"exception details." % (exc))
......@@ -67,7 +67,7 @@ class StandaloneTests(unittest.TestCase):
expected_rc = 1
result = self.run_and_check(cmd_line, expected_rc, 'failtest_nasty2')
self.assertIn("Exception: Unable to get exception, check the traceback"
" for details.", result.stderr)
" for details.", result.stdout)
def test_errortest(self):
cmd_line = './examples/tests/errortest.py'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册