提交 418bf92a 编写于 作者: P Paolo Bonzini

port avocado.plugins.xunit to Python 3

At least, selftests.unit.test_xunit passes.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 8787afc3
......@@ -117,7 +117,7 @@ class XUnitResult(Result):
content = self._render(result)
if getattr(job.args, 'xunit_job_result', 'off') == 'on':
xunit_path = os.path.join(job.logdir, 'results.xml')
with open(xunit_path, 'w') as xunit_file:
with open(xunit_path, 'wb') as xunit_file:
xunit_file.write(content)
xunit_path = getattr(job.args, 'xunit_output', 'None')
......@@ -125,7 +125,7 @@ class XUnitResult(Result):
if xunit_path == '-':
LOG_UI.debug(content)
else:
with open(xunit_path, 'w') as xunit_file:
with open(xunit_path, 'wb') as xunit_file:
xunit_file.write(content)
......
......@@ -4,9 +4,13 @@ import shutil
import tempfile
import unittest
from lxml import etree
from StringIO import StringIO
from xml.dom import minidom
try:
from io import BytesIO
except:
from BytesIO import BytesIO
from avocado import Test
from avocado.core import job
from avocado.core.result import Result
......@@ -57,7 +61,7 @@ class xUnitSucceedTest(unittest.TestCase):
self.test_result.end_tests()
xunit_result = xunit.XUnitResult()
xunit_result.render(self.test_result, self.job)
with open(self.job.args.xunit_output) as fp:
with open(self.job.args.xunit_output, 'rb') as fp:
xml = fp.read()
try:
dom = minidom.parseString(xml)
......@@ -69,7 +73,7 @@ class xUnitSucceedTest(unittest.TestCase):
with open(self.junit, 'r') as f:
xmlschema = etree.XMLSchema(etree.parse(f))
self.assertTrue(xmlschema.validate(etree.parse(StringIO(xml))),
self.assertTrue(xmlschema.validate(etree.parse(BytesIO(xml))),
"Failed to validate against %s, content:\n%s" %
(self.junit, xml))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册