diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-20 04:08:14 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-05-20 04:08:14 +0000 |
| commit | edc0fcdf7cf383e0d76ac727689c2b07530b6bfe (patch) | |
| tree | 191f1167a26253392a2edc77e77e78a6e312af72 /django | |
| parent | c9aa4c71ac316e94beb97307502ae2acf8ef6aed (diff) | |
Moved markup tests into their contrib directory.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/contrib/markup/models.py | 0 | ||||
| -rw-r--r-- | django/contrib/markup/tests.py | 69 |
2 files changed, 69 insertions, 0 deletions
diff --git a/django/contrib/markup/models.py b/django/contrib/markup/models.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/django/contrib/markup/models.py diff --git a/django/contrib/markup/tests.py b/django/contrib/markup/tests.py new file mode 100644 index 0000000000..bd3f52b9dd --- /dev/null +++ b/django/contrib/markup/tests.py @@ -0,0 +1,69 @@ +# Quick tests for the markup templatetags (django.contrib.markup) + +from django.template import Template, Context, add_to_builtins +import re +import unittest + +add_to_builtins('django.contrib.markup.templatetags.markup') + +class Templates(unittest.TestCase): + def test_textile(self): + try: + import textile + except ImportError: + textile = None + + textile_content = """Paragraph 1 + +Paragraph 2 with "quotes" and @code@""" + + t = Template("{{ textile_content|textile }}") + rendered = t.render(Context(locals())).strip() + if textile: + self.assertEqual(rendered, """<p>Paragraph 1</p> + +<p>Paragraph 2 with “quotes” and <code>code</code></p>""") + else: + self.assertEqual(rendered, textile_content) + + def test_markdown(self): + try: + import markdown + except ImportError: + markdown = None + + markdown_content = """Paragraph 1 + +## An h2""" + + t = Template("{{ markdown_content|markdown }}") + rendered = t.render(Context(locals())).strip() + if markdown: + pattern = re.compile("""<p>Paragraph 1\s*</p>\s*<h2>\s*An h2</h2>""") + self.assert_(pattern.match(rendered)) + else: + self.assertEqual(rendered, markdown_content) + + def test_docutils(self): + try: + import docutils + except ImportError: + docutils = None + + rest_content = """Paragraph 1 + +Paragraph 2 with a link_ + +.. _link: http://www.example.com/""" + + t = Template("{{ rest_content|restructuredtext }}") + rendered = t.render(Context(locals())).strip() + if docutils: + self.assertEqual(rendered, """<p>Paragraph 1</p> +<p>Paragraph 2 with a <a class="reference" href="http://www.example.com/">link</a></p>""") + else: + self.assertEqual(rendered, rest_content) + + +if __name__ == '__main__': + unittest.main() |
