2929 skip_stext = mark_class (pytest .mark .skip (
3030 reason = 'StructuredText not available' ))
3131
32+ try :
33+ skip_markdown = lambda func , * args , ** kwargs : func
34+ from markdown2 import markdown
35+ except ImportError :
36+ try :
37+ from markdown import markdown
38+ except ImportError :
39+ markdown = None
40+ skip_markdown = mark_class (pytest .mark .skip (
41+ reason = 'markdown not available' ))
42+
3243from roundup .anypy .strings import u2s , s2u
3344
3445class MockDatabase (MockNull ):
@@ -236,7 +247,21 @@ def test_string_plain_or_hyperlinked(self):
236247
237248 self .
assertEqual (
p .
hyperlinked (),
'A string <b> with <a href="mailto:[email protected] ">[email protected] </a> embedded &lt; html</b>' )
238249
250+ @skip_markdown
251+ def test_string_markdown_installed (self ):
252+ pass # just so we have a record of a skipped test
253+
254+ def test_string_markdown (self ):
255+ p = StringHTMLProperty (
self .
client ,
'test' ,
'1' ,
None ,
'test' ,
u2s (
u'A string http://localhost with [email protected] *embedded* \u00df ' ))
256+ if markdown :
257+ self .
assertEqual (
p .
markdown ().
strip (),
u2s (
u'<p>A string <a href="http://localhost">http://localhost</a> with <a href="mailto:[email protected] ">[email protected] </a> <em>embedded</em> \u00df </p>' ))
258+ else :
259+ self .
assertEqual (
p .
markdown (),
u2s (
u'A string <a href="http://localhost" rel="nofollow noopener">http://localhost</a> with <a href="mailto:[email protected] ">[email protected] </a> *embedded* \u00df ' ))
260+
239261 @skip_rst
262+ def test_string_rst_installed (self ):
263+ pass # just so we have a record of a skipped test
264+
240265 def test_string_rst (self ):
241266 p = StringHTMLProperty (
self .
client ,
'test' ,
'1' ,
None ,
'test' ,
u2s (
u'A string with [email protected] *embedded* \u00df ' ))
242267 if ReStructuredText :
@@ -245,6 +270,9 @@ def test_string_rst(self):
245270 self .
assertEqual (
p .
rst (),
u2s (
u'A string with <a href="mailto:[email protected] ">[email protected] </a> *embedded* \u00df ' ))
246271
247272 @skip_stext
273+ def test_string_stext_installed (self ):
274+ pass # just so we have a record of a skipped test
275+
248276 def test_string_stext (self ):
249277 p = StringHTMLProperty (
self .
client ,
'test' ,
'1' ,
None ,
'test' ,
u2s (
u'A string with [email protected] *embedded* \u00df ' ))
250278 if StructuredText :
0 commit comments