From 97b9ad73b4889ffebb3da2239b472bbfd1600177 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sun, 27 Aug 2006 13:59:47 +0000 Subject: Refs #2333 - Modified runtests script to use new testing framework. Migrated existing tests to use Django testing framework. All the 'othertests' have been migrated into 'regressiontests', and converted into doctests/unittests, as appropriate. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3661 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/markup/tests.py | 69 +++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/regressiontests/markup/tests.py (limited to 'tests/regressiontests/markup/tests.py') diff --git a/tests/regressiontests/markup/tests.py b/tests/regressiontests/markup/tests.py new file mode 100644 index 0000000000..bd3f52b9dd --- /dev/null +++ b/tests/regressiontests/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, """

Paragraph 1

+ +

Paragraph 2 with “quotes” and code

""") + 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("""

Paragraph 1\s*

\s*

\s*An 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, """

Paragraph 1

+

Paragraph 2 with a link

""") + else: + self.assertEqual(rendered, rest_content) + + +if __name__ == '__main__': + unittest.main() -- cgit v1.3