Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
d17e06bd
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d17e06bd
编写于
2月 18, 2019
作者:
C
Caio Carrara
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'clebergnu/test_root_logger'
Signed-off-by:
N
Caio Carrara
<
ccarrara@redhat.com
>
上级
a665956b
beb9dac8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
35 addition
and
0 deletion
+35
-0
avocado/core/test.py
avocado/core/test.py
+5
-0
selftests/functional/test_basic.py
selftests/functional/test_basic.py
+30
-0
未找到文件。
avocado/core/test.py
浏览文件 @
d17e06bd
...
...
@@ -667,6 +667,11 @@ class Test(unittest.TestCase, TestData):
self
.
file_handler
.
setFormatter
(
formatter
)
self
.
log
.
addHandler
(
self
.
file_handler
)
# add the test log handler to the root logger so that
# everything logged while the test is running, for every
# logger, also makes its way into the test log file
logging
.
root
.
addHandler
(
self
.
file_handler
)
stream_fmt
=
'%(message)s'
stream_formatter
=
logging
.
Formatter
(
fmt
=
stream_fmt
)
...
...
selftests/functional/test_basic.py
浏览文件 @
d17e06bd
...
...
@@ -118,6 +118,16 @@ class SharedLibTest(Test):
'''
TEST_OTHER_LOGGERS_CONTENT
=
'''
import logging
from avocado import Test
class My(Test):
def test(self):
logging.getLogger("some.other.logger").info("SHOULD BE ON debug.log")
'''
def
probe_binary
(
binary
):
try
:
return
utils_path
.
find_command
(
binary
)
...
...
@@ -570,6 +580,26 @@ class RunnerOperationTest(unittest.TestCase):
result
.
stdout
)
self
.
assertIn
(
b
"Sleeping for 0.01 seconds"
,
result
.
stdout
)
def
test_other_loggers
(
self
):
with
script
.
TemporaryScript
(
'mytest.py'
,
TEST_OTHER_LOGGERS_CONTENT
,
'avocado_functional_test_other_loggers'
)
as
mytest
:
cmd_line
=
(
'%s run --sysinfo=off --job-results-dir %s '
'-- %s'
%
(
AVOCADO
,
self
.
tmpdir
,
mytest
))
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
expected_rc
=
exit_codes
.
AVOCADO_ALL_OK
self
.
assertEqual
(
result
.
exit_status
,
expected_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
expected_rc
,
result
))
test_log_dir
=
glob
.
glob
(
os
.
path
.
join
(
self
.
tmpdir
,
'job-*'
,
'test-results'
,
'1-*'
))[
0
]
test_log_path
=
os
.
path
.
join
(
test_log_dir
,
'debug.log'
)
with
open
(
test_log_path
,
'rb'
)
as
test_log
:
self
.
assertIn
(
b
'SHOULD BE ON debug.log'
,
test_log
.
read
())
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
tmpdir
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录