Mercurial > p > roundup > code
diff test/test_templating.py @ 6095:3ada6a3f48e1
fixed ReStructuredText encoding with Python 3
| author | Christof Meerwald <cmeerw@cmeerw.org> |
|---|---|
| date | Wed, 19 Feb 2020 22:47:42 +0000 |
| parents | f0da02e0ca81 |
| children | c914b3d8362f |
line wrap: on
line diff
--- a/test/test_templating.py Thu Feb 13 19:51:45 2020 +0000 +++ b/test/test_templating.py Wed Feb 19 22:47:42 2020 +0000 @@ -5,6 +5,13 @@ from roundup.cgi.templating import * from .test_actions import MockNull, true +try: + from docutils.core import publish_parts as ReStructuredText +except ImportError: + ReStructuredText = None + +from roundup.anypy.strings import u2s, s2u + class MockDatabase(MockNull): def getclass(self, name): return self.classes[name] @@ -210,6 +217,13 @@ self.assertEqual(p.hyperlinked(), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') + def test_string_rst(self): + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df')) + if ReStructuredText: + self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n</div>\n')) + else: + self.assertEqual(p.rst(), u2s(u'A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> *embedded* \u00df')) + def test_string_field(self): p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded < html</b>') self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string <b> with rouilj@example.com embedded &lt; html</b>">')
