Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 6094:dd6a54d8a22a | 6095:3ada6a3f48e1 |
|---|---|
| 2 import unittest | 2 import unittest |
| 3 from cgi import FieldStorage, MiniFieldStorage | 3 from cgi import FieldStorage, MiniFieldStorage |
| 4 | 4 |
| 5 from roundup.cgi.templating import * | 5 from roundup.cgi.templating import * |
| 6 from .test_actions import MockNull, true | 6 from .test_actions import MockNull, true |
| 7 | |
| 8 try: | |
| 9 from docutils.core import publish_parts as ReStructuredText | |
| 10 except ImportError: | |
| 11 ReStructuredText = None | |
| 12 | |
| 13 from roundup.anypy.strings import u2s, s2u | |
| 7 | 14 |
| 8 class MockDatabase(MockNull): | 15 class MockDatabase(MockNull): |
| 9 def getclass(self, name): | 16 def getclass(self, name): |
| 10 return self.classes[name] | 17 return self.classes[name] |
| 11 | 18 |
| 207 self.assertEqual(p.plain(escape=1), 'A string <b> with rouilj@example.com embedded &lt; html</b>') | 214 self.assertEqual(p.plain(escape=1), 'A string <b> with rouilj@example.com embedded &lt; html</b>') |
| 208 self.assertEqual(p.plain(hyperlink=1), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') | 215 self.assertEqual(p.plain(hyperlink=1), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') |
| 209 self.assertEqual(p.plain(escape=1, hyperlink=1), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') | 216 self.assertEqual(p.plain(escape=1, hyperlink=1), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') |
| 210 | 217 |
| 211 self.assertEqual(p.hyperlinked(), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') | 218 self.assertEqual(p.hyperlinked(), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') |
| 219 | |
| 220 def test_string_rst(self): | |
| 221 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df')) | |
| 222 if ReStructuredText: | |
| 223 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')) | |
| 224 else: | |
| 225 self.assertEqual(p.rst(), u2s(u'A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> *embedded* \u00df')) | |
| 212 | 226 |
| 213 def test_string_field(self): | 227 def test_string_field(self): |
| 214 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded < html</b>') | 228 p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with rouilj@example.com embedded < html</b>') |
| 215 self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string <b> with rouilj@example.com embedded &lt; html</b>">') | 229 self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string <b> with rouilj@example.com embedded &lt; html</b>">') |
| 216 | 230 |
