Mercurial > p > roundup > code
diff test/test_templating.py @ 6096:c914b3d8362f
If rst missing skip; initial attempt to test structuredtext.
Try to set up structured text testing. I can't get StructuredText to
run under python3, but this test passes under python2. Once I get
StructuredText to pass under p3, I'll install StructuredText to ci
and these tests won't be skipped.
Also if import for reStructuredText fails, skip the test rather than
silently passing.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 19 Feb 2020 22:12:06 -0500 |
| parents | 3ada6a3f48e1 |
| children | 90a1470edbea |
line wrap: on
line diff
--- a/test/test_templating.py Wed Feb 19 22:47:42 2020 +0000 +++ b/test/test_templating.py Wed Feb 19 22:12:06 2020 -0500 @@ -5,10 +5,29 @@ from roundup.cgi.templating import * from .test_actions import MockNull, true + +import pytest +from .pytest_patcher import mark_class + try: from docutils.core import publish_parts as ReStructuredText + skip_rst = lambda func, *args, **kwargs: func except ImportError: ReStructuredText = None + skip_rst = mark_class(pytest.mark.skip( + reason='ReStructuredText not available')) + +try: + from StructuredText.StructuredText import HTML as StructuredText + skip_stext = lambda func, *args, **kwargs: func +except ImportError: + try: # older version + import StructuredText + skip_stext = lambda func, *args, **kwargs: func + except ImportError: + StructuredText = None + skip_stext = mark_class(pytest.mark.skip( + reason='StructuredText not available')) from roundup.anypy.strings import u2s, s2u @@ -217,6 +236,7 @@ self.assertEqual(p.hyperlinked(), 'A string <b> with <a href="mailto:rouilj@example.com">rouilj@example.com</a> embedded &lt; html</b>') + @skip_rst 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: @@ -224,6 +244,14 @@ else: self.assertEqual(p.rst(), u2s(u'A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> *embedded* \u00df')) + @skip_stext + def test_string_stext(self): + p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with cmeerw@example.com *embedded* \u00df')) + if StructuredText: + self.assertEqual(p.stext(), u2s(u'<p>A string with <a href="mailto:cmeerw@example.com">cmeerw@example.com</a> <em>embedded</em> \u00df</p>\n')) + else: + self.assertEqual(p.stext(), 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>">')
