def test_render_fallback_markup_comment(self): with patch.multiple('django_comments_xtd.conf.settings', COMMENTS_XTD_MARKUP_FALLBACK_FILTER=None): comment = r'''An [example](http://url.com/ "Title")''' result = render_markup_comment(comment) self.assertEqual(result, r'''An [example](http://url.com/ "Title")''')
def test_render_markup_comment_in_markdown(self): comment = r'''#!markdown An [example](http://url.com/ "Title")''' result = render_markup_comment(comment) self.assertEqual( result, '<p>An <a href="http://url.com/" title="Title">example</a></p>')
def test_render_markup_comment_in_restructuredtext(self): comment = ('#!restructuredtext\n' 'A fibonacci generator in Python, taken from ' '`LiteratePrograms <http://en.literateprograms.org/' 'Fibonacci_numbers_%28Python%29>`_::\n\n' ' def fib():\n' ' a, b = 0, 1\n' ' while 1:\n' ' yield a\n' ' a, b = b, a + b') result = render_markup_comment(comment) self.assertEqual(result, ('<div class="document">\n' '<p>A fibonacci generator in Python, taken from ' '<a class="reference external" href="http://en.' 'literateprograms.org/Fibonacci_numbers_%28' 'Python%29">LiteratePrograms</a>:</p>\n' '<pre class="literal-block">\n' 'def fib():\n' ' a, b = 0, 1\n' ' while 1:\n' ' yield a\n' ' a, b = b, a + b\n' '</pre>\n' '</div>\n'))
def test_render_fallback_markup_comment(self): with patch.multiple('django_comments_xtd.conf.settings', COMMENTS_XTD_MARKUP_FALLBACK_FILTER='markdown'): comment = r'''An [example](http://url.com/ "Title")''' result = render_markup_comment(comment) self.assertEqual(result, '<p>An <a href="http://url.com/" title="Title">example</a></p>')
def test_render_fallback_markup_comment_markdown(self): with patch.multiple('django_comments_xtd.conf.settings', COMMENTS_XTD_MARKUP_FALLBACK_FILTER='markdown'): comment = r'''An [example](http://url.com/ "Title")''' result = render_markup_comment(comment) self.assertEqual( result, '<p>An <a href="http://url.com/" ' 'title="Title">example</a></p>')
def test_render_markup_comment_in_restructuredtext(self): comment = r'''#!restructuredtext A fibonacci generator in Python, taken from `LiteratePrograms <http://en.literateprograms.org/Fibonacci_numbers_%28Python%29>`_:: def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b''' result = render_markup_comment(comment) self.assertEqual(result, r'''<p>A fibonacci generator in Python, taken from <a class="reference external" href="http://en.literateprograms.org/Fibonacci_numbers_%28Python%29">LiteratePrograms</a>:</p> <pre class="literal-block"> def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b </pre> ''')
def test_render_markup_comment_in_restructuredtext(self): comment = r'''#!restructuredtext A fibonacci generator in Python, taken from `LiteratePrograms <http://en.literateprograms.org/Fibonacci_numbers_%28Python%29>`_:: def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b''' result = render_markup_comment(comment) self.assertEqual( result, r'''<p>A fibonacci generator in Python, taken from <a class="reference external" href="http://en.literateprograms.org/Fibonacci_numbers_%28Python%29">LiteratePrograms</a>:</p> <pre class="literal-block"> def fib(): a, b = 0, 1 while 1: yield a a, b = b, a + b </pre> ''')
def test_render_markup_comment_in_markdown(self): comment = r'''#!markdown An [example](http://url.com/ "Title")''' result = render_markup_comment(comment) self.assertEqual(result, '<p>An <a href="http://url.com/" title="Title">example</a></p>')