diff --git a/tests/othertests/markup.py b/tests/othertests/markup.py index 0489b16b30..b1ffb99c8a 100644 --- a/tests/othertests/markup.py +++ b/tests/othertests/markup.py @@ -1,24 +1,56 @@ # Quick tests for the markup templatetags (django.contrib.markup) -# -# Requires that all supported markup modules be installed -# (http://dealmeida.net/projects/textile/, -# http://www.freewisdom.org/projects/python-markdown, and -# http://docutils.sf.net/) - from django.core.template import Template, Context import django.contrib.markup.templatetags.markup # this registers the filters +# find out if markup modules are installed and tailor the test appropriately +try: + import textile +except ImportError: + textile = None + +try: + import markdown +except ImportError: + markdown = None + +try: + import docutils +except ImportError: + docutils = None + # simple examples 'cause this isn't actually testing the markup, just # that the filters work as advertised +### test textile + textile_content = """Paragraph 1 Paragraph 2 with "quotes" and @code@""" +t = Template("{{ textile_content|textile }}") +rendered = t.render(Context(locals())).strip() +if textile: + assert rendered == """
Paragraph 1
+ +Paragraph 2 with “quotes” and code
Paragraph 1
Paragraph 1
- -Paragraph 2 with “quotes” and code
Paragraph 1
Paragraph 1
-Paragraph 2 with a link
""" \ No newline at end of file +t = Template("{{ rest_content|restructuredtext }}") +rendered = t.render(Context(locals())).strip() +if docutils: + assert rendered =="""Paragraph 1
+Paragraph 2 with a link
""" +else: + assert rendered == rest_content \ No newline at end of file