提交 952e4456 编写于 作者: L Lukáš Doktor

avocado.core.output: Fix the --show log level parsing

The --show stream:level is actually broken as the "name" variable is not
tuple, but only the stream name. The variable was renamed to
"stream_level" instead.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 ea1f6221
......@@ -423,8 +423,8 @@ def reconfigure(args):
if len(stream_level) == 1:
level = logging.DEBUG
else:
level = (int(name[1]) if name[1].isdigit()
else logging.getLevelName(name[1].upper()))
level = (int(stream_level[1]) if stream_level[1].isdigit()
else logging.getLevelName(stream_level[1].upper()))
try:
add_log_handler(name, logging.StreamHandler, STD_OUTPUT.stdout,
level)
......
......@@ -114,6 +114,29 @@ class StreamsTest(unittest.TestCase):
self.assertEqual('', result.stdout)
self.assertNotEqual('', result.stderr)
def test_custom_stream_and_level(self):
"""
Checks if "--show stream:level" works for non-built-in-streams
"""
def run(show, no_lines):
result = process.run("./scripts/avocado --show %s config" % show)
out = (result.stdout + result.stderr).splitlines()
if no_lines == "more_than_one":
self.assertGreater(len(out), 1, "Output of %s should contain "
"more than 1 line, contains only %s\n%s"
% (result.command, len(out), result))
else:
self.assertEqual(len(out), no_lines, "Output of %s should "
"contain %s lines, contains %s instead\n%s"
% (result.command, no_lines, len(out),
result))
run("avocado.app:dEbUg", "more_than_one")
run("avocado.app:0", "more_than_one")
run("avocado.app:InFo", 1)
run("avocado.app:20", 1)
run("avocado.app:wARn", 0)
run("avocado.app:30", 0)
def tearDown(self):
shutil.rmtree(self.tmpdir)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册