[PATCH 08 of 17 seda] [py3] Force XML serialization to unicode in html generation tests

Denis Laxalde denis.laxalde at logilab.fr
Wed Oct 2 16:06:36 CEST 2019


In python3, lxml.etree.tostring returns bytes but we expect text in
tests. By passing six.text_type as encoding parameter to this function,
it returns a unicode string.

diff --git a/test/test_html_generation.py b/test/test_html_generation.py
index 7ebebe9..8c78e36 100644
--- a/test/test_html_generation.py
+++ b/test/test_html_generation.py
@@ -18,6 +18,7 @@
 from collections import namedtuple
 
 from lxml import etree
+from six import text_type
 
 from cubicweb.devtools.testlib import CubicWebTC
 
@@ -60,7 +61,7 @@ class SEDAHTMLExportFuncTC(SEDAExportFun
             el_defs.append(el_def)
             for span in self.xpath(div, 'span'):
                 if len(span):
-                    value = etree.tostring(span[0])
+                    value = etree.tostring(span[0], encoding=text_type)
                 else:
                     value = span.text
                 el_def[span.attrib['class']] = value



More information about the saem-devel mailing list