|
5 | 5 | from roundup.cgi.templating import * |
6 | 6 | from .test_actions import MockNull, true |
7 | 7 |
|
| 8 | + |
| 9 | +import pytest |
| 10 | +from .pytest_patcher import mark_class |
| 11 | + |
8 | 12 | try: |
9 | 13 | from docutils.core import publish_parts as ReStructuredText |
| 14 | + skip_rst = lambda func, *args, **kwargs: func |
10 | 15 | except ImportError: |
11 | 16 | 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')) |
12 | 31 |
|
13 | 32 | from roundup.anypy.strings import u2s, s2u |
14 | 33 |
|
@@ -217,13 +236,22 @@ def test_string_plain_or_hyperlinked(self): |
217 | 236 |
|
218 | 237 | self. assertEqual( p. hyperlinked(), 'A string <b> with <a href="mailto:[email protected]">[email protected]</a> embedded &lt; html</b>') |
219 | 238 |
|
| 239 | + @skip_rst |
220 | 240 | def test_string_rst(self): |
221 | 241 | p = StringHTMLProperty( self. client, 'test', '1', None, 'test', u2s( u'A string with [email protected] *embedded* \u00df')) |
222 | 242 | if ReStructuredText: |
223 | 243 | 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 | 244 | else: |
225 | 245 | self. assertEqual( p. rst(), u2s( u'A string with <a href="mailto:[email protected]">[email protected]</a> *embedded* \u00df')) |
226 | 246 |
|
| 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 | + |
227 | 255 | def test_string_field(self): |
228 | 256 | p = StringHTMLProperty( self. client, 'test', '1', None, 'test', 'A string <b> with [email protected] embedded < html</b>') |
229 | 257 | self. assertEqual( p. field(), '<input name="test1@test" size="30" type="text" value="A string <b> with [email protected] embedded &lt; html</b>">') |
|
0 commit comments