Skip to content

Commit 06d0d61

Browse files
committed
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.
1 parent fded99d commit 06d0d61

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/test_templating.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,29 @@
55
from roundup.cgi.templating import *
66
from .test_actions import MockNull, true
77

8+
9+
import pytest
10+
from .pytest_patcher import mark_class
11+
812
try:
913
from docutils.core import publish_parts as ReStructuredText
14+
skip_rst = lambda func, *args, **kwargs: func
1015
except ImportError:
1116
ReStructuredText = None
17+
skip_rst = mark_class(pytest.mark.skip(
18+
reason='ReStructuredText not available'))
19+
20+
try:
21+
from StructuredText.StructuredText import HTML as StructuredText
22+
skip_stext = lambda func, *args, **kwargs: func
23+
except ImportError:
24+
try: # older version
25+
import StructuredText
26+
skip_stext = lambda func, *args, **kwargs: func
27+
except ImportError:
28+
StructuredText = None
29+
skip_stext = mark_class(pytest.mark.skip(
30+
reason='StructuredText not available'))
1231

1332
from roundup.anypy.strings import u2s, s2u
1433

@@ -217,13 +236,22 @@ def test_string_plain_or_hyperlinked(self):
217236

218237
self.assertEqual(p.hyperlinked(), 'A string &lt;b&gt; with <a href="mailto:[email protected]">[email protected]</a> embedded &amp;lt; html&lt;/b&gt;')
219238

239+
@skip_rst
220240
def test_string_rst(self):
221241
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with [email protected] *embedded* \u00df'))
222242
if ReStructuredText:
223243
self.assertEqual(p.rst(), u2s(u'<div class="document">\n<p>A string with <a class="reference external" href="mailto:cmeerw&#64;example.com">cmeerw&#64;example.com</a> <em>embedded</em> \u00df</p>\n</div>\n'))
224244
else:
225245
self.assertEqual(p.rst(), u2s(u'A string with <a href="mailto:[email protected]">[email protected]</a> *embedded* \u00df'))
226246

247+
@skip_stext
248+
def test_string_stext(self):
249+
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', u2s(u'A string with [email protected] *embedded* \u00df'))
250+
if StructuredText:
251+
self.assertEqual(p.stext(), u2s(u'<p>A string with <a href="mailto:[email protected]">[email protected]</a> <em>embedded</em> \u00df</p>\n'))
252+
else:
253+
self.assertEqual(p.stext(), u2s(u'A string with <a href="mailto:[email protected]">[email protected]</a> *embedded* \u00df'))
254+
227255
def test_string_field(self):
228256
p = StringHTMLProperty(self.client, 'test', '1', None, 'test', 'A string <b> with [email protected] embedded &lt; html</b>')
229257
self.assertEqual(p.field(), '<input name="test1@test" size="30" type="text" value="A string &lt;b&gt; with [email protected] embedded &amp;lt; html&lt;/b&gt;">')

0 commit comments

Comments
 (0)