[PATCH 09 of 16 eac] [py3] Serialize to unicode in etree.tostring()

Denis Laxalde denis.laxalde at logilab.fr
Tue Oct 1 12:36:35 CEST 2019


# HG changeset patch
# User Denis Laxalde <denis.laxalde at logilab.fr>
# Date 1569920840 -7200
#      Tue Oct 01 11:07:20 2019 +0200
# Node ID 1b87b40790f6558e399d1d6f6c89186a622a2df2
# Parent  9981e1a4c587066b5ddc3736faab8d8a20992a96
# Available At http://hg.logilab.org/review/cubes/eac
#              hg pull http://hg.logilab.org/review/cubes/eac -r 1b87b40790f6
[py3] Serialize to unicode in etree.tostring()

diff --git a/test/test_entities.py b/test/test_entities.py
index bb2c482..049556c 100644
--- a/test/test_entities.py
+++ b/test/test_entities.py
@@ -18,6 +18,7 @@
 
 
 from lxml import etree
+from six import text_type
 
 from cubicweb.devtools.testlib import CubicWebTC
 
@@ -57,7 +58,7 @@ class EACExportTC(CubicWebTC):
             tag, = serializer._eac_richstring_paragraph_elements(
                 mandate, 'description')
         self.assertEqual(tag.tag, 'span')
-        self.assertIn(desc, etree.tostring(tag))
+        self.assertIn(desc, etree.tostring(tag, encoding=text_type))
 
     def test_richstring_html_multiple_elements(self):
         with self.admin_access.cnx() as cnx:
@@ -73,8 +74,8 @@ class EACExportTC(CubicWebTC):
                 mandate, 'description')
         self.assertEqual(h1.tag, 'h1')
         self.assertEqual(a.tag, 'a')
-        self.assertIn(etree.tostring(h1), desc[0])
-        self.assertIn(etree.tostring(a), desc[1])
+        self.assertIn(etree.tostring(h1, encoding=text_type), desc[0])
+        self.assertIn(etree.tostring(a, encoding=text_type), desc[1])
 
     def test_richstring_markdown(self):
         with self.admin_access.cnx() as cnx:
@@ -93,7 +94,7 @@ class EACExportTC(CubicWebTC):
             tag, = serializer._eac_richstring_paragraph_elements(
                 mandate, 'description')
         self.assertEqual(tag.tag, 'p')
-        self.assertIn(desc_html, etree.tostring(tag))
+        self.assertIn(desc_html, etree.tostring(tag, encoding=text_type))
 
     def test_richstring_rest(self):
         with self.admin_access.cnx() as cnx:
@@ -112,7 +113,7 @@ class EACExportTC(CubicWebTC):
             ptag, = serializer._eac_richstring_paragraph_elements(
                 mandate, 'description')
         self.assertEqual(ptag.tag, 'p')
-        self.assertIn(desc_html, etree.tostring(ptag))
+        self.assertIn(desc_html, etree.tostring(ptag, encoding=text_type))
 
     def test_richstring_empty(self):
         def check(authority_record):



More information about the saem-devel mailing list