[testlib/fix] erronus combination of bytes and str

authorLaurent Peuch <cortex@worlddomination.be>
changesetc5cb00dbdaa6
branchdefault
phasedraft
hiddenno
parent revision#a4d465a3e77d fix(ci): manually remove the .tox/doc directory
child revision<not specified>
files modified by this revision
cubicweb/devtools/htmlparser.py
cubicweb/devtools/testlib.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1574904204 -3600
# Thu Nov 28 02:23:24 2019 +0100
# Node ID c5cb00dbdaa6f30d8894269e13487bfe4dcdec03
# Parent a4d465a3e77d07cf6a79c121c10b2d6484cd7468
[testlib/fix] erronus combination of bytes and str

diff --git a/cubicweb/devtools/htmlparser.py b/cubicweb/devtools/htmlparser.py
@@ -66,10 +66,12 @@
1      # >>> cleaner.clean_html('<html><body><div/><br><span></body><html>')
2      # '<html><body><div></div><br><span></span></body></html>'
3      #
4      # using that, we'll miss most actual validation error we want to
5      # catch. For now, use dumb regexp
6 +    if isinstance(data, str):
7 +        data = data.encode()
8      return _REM_SCRIPT_RGX.sub(b'', data)
9 
10 
11  class Validator(object):
12      """ base validator API """
diff --git a/cubicweb/devtools/testlib.py b/cubicweb/devtools/testlib.py
@@ -959,11 +959,11 @@
13                      # XXX no need to iterate the whole file except to get
14                      # the line number
15                      content = u'\n'.join(line_template % (idx + 1, line)
16                                           for idx, line in enumerate(content)
17                                           if line_context_filter(idx + 1, position))
18 -                    msg += u'\nfor content:\n%s' % content
19 +                    msg += b'\nfor content:\n%s' % content.encode()
20              exc = AssertionError(msg)
21              exc.__traceback__ = tcbk
22              raise exc
23 
24      def assertDocTestFile(self, testfile):