Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
f523ed7d
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,发现更多精彩内容 >>
提交
f523ed7d
编写于
6月 05, 2014
作者:
R
Rudá Moura
提交者:
Rudá Moura
6月 05, 2014
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #86 from avocado-framework/fix-xunit-bug
Fix xunit bug
上级
b5417390
852146e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
69 addition
and
3 deletion
+69
-3
avocado/plugins/xunit.py
avocado/plugins/xunit.py
+2
-2
selftests/all/functional/avocado/basic_tests.py
selftests/all/functional/avocado/basic_tests.py
+67
-1
未找到文件。
avocado/plugins/xunit.py
浏览文件 @
f523ed7d
...
...
@@ -130,8 +130,8 @@ class XmlResult(object):
:param test: an instance of :class:`avocado.test.Test`.
"""
tc
=
'''
\t
<testcase classname=
"{class}" name="{name}"
time="{time}">
\t\t
<error type=
"{type}"
message={reason}><![CDATA[{traceback}]]></error>
tc
=
'''
\t
<testcase classname=
{class} name={name}
time="{time}">
\t\t
<error type=
{type}
message={reason}><![CDATA[{traceback}]]></error>
\t\t
<system-out><![CDATA[{systemout}]]></system-out>
\t
</testcase>'''
values
=
{
'class'
:
self
.
_escape_attr
(
test
.
__class__
.
__name__
),
...
...
selftests/all/functional/avocado/basic_tests.py
浏览文件 @
f523ed7d
...
...
@@ -19,6 +19,7 @@ import os
import
shutil
import
sys
import
tempfile
import
xml.dom.minidom
# simple magic for using scripts within a source tree
basedir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'..'
,
'..'
,
'..'
,
'..'
)
...
...
@@ -101,7 +102,7 @@ class RunnerDropinTest(unittest.TestCase):
shutil
.
rmtree
(
self
.
base_logdir
,
ignore_errors
=
True
)
class
Plugins
Operation
Test
(
unittest
.
TestCase
):
class
Plugins
Sysinfo
Test
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
base_outputdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_plugins'
)
...
...
@@ -122,5 +123,70 @@ class PluginsOperationTest(unittest.TestCase):
shutil
.
rmtree
(
self
.
base_outputdir
,
ignore_errors
=
True
)
class
ParseXMLError
(
Exception
):
pass
class
PluginsXunitTest
(
PluginsSysinfoTest
):
def
run_and_check
(
self
,
testname
,
e_rc
,
e_ntests
,
e_nerrors
,
e_nfailures
,
e_nskip
):
os
.
chdir
(
basedir
)
cmd_line
=
'./scripts/avocado --xunit run %s'
%
testname
result
=
process
.
run
(
cmd_line
,
ignore_status
=
True
)
xml_output
=
result
.
stdout
self
.
assertEqual
(
result
.
exit_status
,
e_rc
,
"Avocado did not return rc %d:
\n
%s"
%
(
e_rc
,
result
))
try
:
xunit_doc
=
xml
.
dom
.
minidom
.
parseString
(
xml_output
)
except
Exception
,
detail
:
raise
ParseXMLError
(
"Failed to parse content: %s
\n
%s"
%
(
detail
,
xml_output
))
testsuite_list
=
xunit_doc
.
getElementsByTagName
(
'testsuite'
)
self
.
assertEqual
(
len
(
testsuite_list
),
1
,
'More than one testsuite tag'
)
testsuite_tag
=
testsuite_list
[
0
]
self
.
assertEqual
(
len
(
testsuite_tag
.
attributes
),
7
,
'Less than 7 attributes in the testsuite tag. '
'XML:
\n
%s'
%
xml_output
)
n_tests
=
int
(
testsuite_tag
.
attributes
[
'tests'
].
value
)
self
.
assertEqual
(
n_tests
,
e_ntests
,
"Unexpected number of executed tests, "
"XML:
\n
%s"
%
xml_output
)
n_errors
=
int
(
testsuite_tag
.
attributes
[
'errors'
].
value
)
self
.
assertEqual
(
n_errors
,
e_nerrors
,
"Unexpected number of test errors, "
"XML:
\n
%s"
%
xml_output
)
n_failures
=
int
(
testsuite_tag
.
attributes
[
'failures'
].
value
)
self
.
assertEqual
(
n_failures
,
e_nfailures
,
"Unexpected number of test failures, "
"XML:
\n
%s"
%
xml_output
)
n_skip
=
int
(
testsuite_tag
.
attributes
[
'skip'
].
value
)
self
.
assertEqual
(
n_skip
,
e_nskip
,
"Unexpected number of test skips, "
"XML:
\n
%s"
%
xml_output
)
def
test_xunit_plugin_sleeptest
(
self
):
self
.
run_and_check
(
'sleeptest'
,
0
,
1
,
0
,
0
,
0
)
def
test_xunit_plugin_failtest
(
self
):
self
.
run_and_check
(
'failtest'
,
1
,
1
,
0
,
1
,
0
)
def
test_xunit_plugin_skiptest
(
self
):
self
.
run_and_check
(
'skiptest'
,
0
,
1
,
0
,
0
,
1
)
def
test_xunit_plugin_errortest
(
self
):
self
.
run_and_check
(
'errortest'
,
1
,
1
,
1
,
0
,
0
)
def
test_xunit_plugin_mixedtest
(
self
):
self
.
run_and_check
(
'"sleeptest failtest skiptest errortest"'
,
1
,
4
,
1
,
1
,
1
)
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录