[py3] Force XML serialization to unicode in html generation tests
authorDenis Laxalde <denis.laxalde@logilab.fr>
Wed, 02 Oct 2019 14:21:25 +0200
changeset 3040 12ef95c411d0
parent 3039 f14dfe93073a
child 3041 e7bc12390c5d
[py3] Force XML serialization to unicode in html generation tests 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.
test/test_html_generation.py
--- a/test/test_html_generation.py	Wed Oct 02 14:18:01 2019 +0200
+++ b/test/test_html_generation.py	Wed Oct 02 14:21:25 2019 +0200
@@ -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 @@
             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