Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
3aa81b0a
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,发现更多精彩内容 >>
未验证
提交
3aa81b0a
编写于
4月 04, 2017
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'apahim/fix_xunit_on_test_fail_v2'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
424ee498
47a5ec2b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
9 deletion
+26
-9
avocado/plugins/xunit.py
avocado/plugins/xunit.py
+9
-4
selftests/.data/junit-4.xsd
selftests/.data/junit-4.xsd
+0
-0
selftests/functional/test_basic.py
selftests/functional/test_basic.py
+13
-1
selftests/unit/test_xunit.py
selftests/unit/test_xunit.py
+4
-4
未找到文件。
avocado/plugins/xunit.py
浏览文件 @
3aa81b0a
...
...
@@ -69,8 +69,7 @@ class XUnitResult(Result):
system_out_cdata_content
=
self
.
_escape_cdata
(
text_output
)
system_out_cdata
=
document
.
createCDATASection
(
system_out_cdata_content
)
system_out
.
appendChild
(
system_out_cdata
)
element
.
appendChild
(
system_out
)
return
element
return
element
,
system_out
def
_render
(
self
,
result
):
document
=
Document
()
...
...
@@ -91,13 +90,19 @@ class XUnitResult(Result):
elif
status
==
'SKIP'
:
testcase
.
appendChild
(
Element
(
'skipped'
))
elif
status
==
'FAIL'
:
element
=
self
.
_create_failure_or_error
(
document
,
test
,
'failure'
)
element
,
system_out
=
self
.
_create_failure_or_error
(
document
,
test
,
'failure'
)
testcase
.
appendChild
(
element
)
testcase
.
appendChild
(
system_out
)
elif
status
==
'CANCEL'
:
testcase
.
appendChild
(
Element
(
'skipped'
))
else
:
element
=
self
.
_create_failure_or_error
(
document
,
test
,
'error'
)
element
,
system_out
=
self
.
_create_failure_or_error
(
document
,
test
,
'error'
)
testcase
.
appendChild
(
element
)
testcase
.
appendChild
(
system_out
)
testsuite
.
appendChild
(
testcase
)
return
document
.
toprettyxml
(
encoding
=
'UTF-8'
)
...
...
selftests/
unit
/junit-4.xsd
→
selftests/
.data
/junit-4.xsd
浏览文件 @
3aa81b0a
文件已移动
selftests/functional/test_basic.py
浏览文件 @
3aa81b0a
...
...
@@ -13,9 +13,11 @@ import xml.dom.minidom
import
zipfile
import
unittest
import
psutil
import
pkg_resources
from
lxml
import
etree
from
StringIO
import
StringIO
from
avocado.core
import
exit_codes
from
avocado.utils
import
astring
from
avocado.utils
import
process
...
...
@@ -1013,6 +1015,8 @@ class PluginsXunitTest(AbsPluginsTest, unittest.TestCase):
def
setUp
(
self
):
self
.
tmpdir
=
tempfile
.
mkdtemp
(
prefix
=
'avocado_'
+
__name__
)
self
.
junit
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
pardir
,
".data"
,
'junit-4.xsd'
))
super
(
PluginsXunitTest
,
self
).
setUp
()
def
run_and_check
(
self
,
testname
,
e_rc
,
e_ntests
,
e_nerrors
,
...
...
@@ -1031,6 +1035,14 @@ class PluginsXunitTest(AbsPluginsTest, unittest.TestCase):
raise
ParseXMLError
(
"Failed to parse content: %s
\n
%s"
%
(
detail
,
xml_output
))
with
open
(
self
.
junit
,
'r'
)
as
f
:
xmlschema
=
etree
.
XMLSchema
(
etree
.
parse
(
f
))
self
.
assertTrue
(
xmlschema
.
validate
(
etree
.
parse
(
StringIO
(
xml_output
))),
"Failed to validate against %s, message:
\n
%s"
%
(
self
.
junit
,
xmlschema
.
error_log
.
filter_from_errors
()))
testsuite_list
=
xunit_doc
.
getElementsByTagName
(
'testsuite'
)
self
.
assertEqual
(
len
(
testsuite_list
),
1
,
'More than one testsuite tag'
)
...
...
selftests/unit/test_xunit.py
浏览文件 @
3aa81b0a
...
...
@@ -43,8 +43,8 @@ class xUnitSucceedTest(unittest.TestCase):
self
.
test1
=
SimpleTest
(
job
=
self
.
job
,
base_logdir
=
self
.
tmpdir
)
self
.
test1
.
_Test__status
=
'PASS'
self
.
test1
.
time_elapsed
=
1.23
unittests_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
self
.
junit_schema_path
=
os
.
path
.
join
(
unittests_path
,
'junit-4.xsd'
)
self
.
junit
=
os
.
path
.
abspath
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
os
.
path
.
pardir
,
".data"
,
'junit-4.xsd'
)
)
def
tearDown
(
self
):
os
.
close
(
self
.
tmpfile
[
0
])
...
...
@@ -67,11 +67,11 @@ class xUnitSucceedTest(unittest.TestCase):
els
=
dom
.
getElementsByTagName
(
'testcase'
)
self
.
assertEqual
(
len
(
els
),
1
)
with
open
(
self
.
junit
_schema_path
,
'r'
)
as
f
:
with
open
(
self
.
junit
,
'r'
)
as
f
:
xmlschema
=
etree
.
XMLSchema
(
etree
.
parse
(
f
))
self
.
assertTrue
(
xmlschema
.
validate
(
etree
.
parse
(
StringIO
(
xml
))),
"Failed to validate against %s, content:
\n
%s"
%
(
self
.
junit
_schema_path
,
xml
))
(
self
.
junit
,
xml
))
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录