[Piglit] [PATCH 33/44] Framework/backends/junit.py: fix bytes/unicode handling on python3
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Wed Jan 27 16:06:41 PST 2016
From: Dylan Baker <baker.dylan.c at gmail.com>
This changes the junit.py script to always convert bytes into unicode
before writing, since we do declare that our xml is encoded in unicode.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/backends/junit.py | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index 062c061..f9eec66 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -25,12 +25,13 @@ from __future__ import (
)
import os.path
import shutil
-
try:
from lxml import etree
except ImportError:
import xml.etree.cElementTree as etree
+import six
+
from framework import grouptools, results, status, exceptions
from framework.core import PIGLIT_CONFIG
from .abstract import FileBackend
@@ -113,9 +114,10 @@ class JUnitBackend(FileBackend):
f.write("<?xml version='1.0' encoding='utf-8'?>\n")
# lxml has a pretty print we want to use
if etree.__name__ == 'lxml.etree':
- f.write(etree.tostring(root, pretty_print=True))
+ out = etree.tostring(root, pretty_print=True)
else:
- f.write(etree.tostring(root))
+ out = etree.tostring(root)
+ f.write(out.decode('utf-8'))
shutil.rmtree(os.path.join(self._dest, 'tests'))
@@ -220,7 +222,7 @@ class JUnitBackend(FileBackend):
else:
etree.SubElement(element, 'failure', message='Incomplete run.')
- f.write(etree.tostring(element))
+ f.write(six.text_type(etree.tostring(element).decode('utf-8')))
def _load(results_file):
--
2.7.0
More information about the Piglit
mailing list