[py3] Use "utf-8" as input encoding for docutils in rest extension
Docutils says that "unicode" is an unknown encoding on Python3. Not sure
where "unicode" as an encoding comes (it's there since showtime) but
"utf-8" seems more appropriate.
From now on, rendering of CubicWeb's rst directive (e.g. ..winclude)
works on Python 3. Accordingly, we extend wdoc's test to demonstrate
this. For this we need to install docutils in tox's web environment.
--- a/cubicweb/ext/rest.py Thu Jun 28 11:19:14 2018 +0200
+++ b/cubicweb/ext/rest.py Thu Jun 28 12:19:16 2018 +0200
@@ -404,7 +404,7 @@
"""
req = context._cw
if isinstance(data, text_type):
- encoding = 'unicode'
+ encoding = 'utf-8'
# remove unprintable characters unauthorized in xml
data = data.translate(ESC_UCAR_TABLE)
else:
--- a/cubicweb/web/test/unittest_views_wdoc.py Thu Jun 28 11:19:14 2018 +0200
+++ b/cubicweb/web/test/unittest_views_wdoc.py Thu Jun 28 12:19:16 2018 +0200
@@ -7,6 +7,9 @@
with self.admin_access.web_request(fid='main') as req:
page = req.view('wdoc')
self.assertIn(u'Site documentation', page)
+ # This part is renderend through rst extension (..winclude directive).
+ self.assertIn(u'This web application is based on the CubicWeb knowledge management system',
+ page)
if __name__ == '__main__':
--- a/requirements/test-web.txt Thu Jun 28 11:19:14 2018 +0200
+++ b/requirements/test-web.txt Thu Jun 28 12:19:16 2018 +0200
@@ -1,3 +1,4 @@
+docutils
Twisted < 16.0.0
requests
webtest