summaryrefslogtreecommitdiff
path: root/src/Tests/Filters.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/Tests/Filters.py')
-rw-r--r--src/Tests/Filters.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/Tests/Filters.py b/src/Tests/Filters.py
new file mode 100644
index 0000000..04afdd5
--- /dev/null
+++ b/src/Tests/Filters.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+import sys
+
+import Cheetah.Template
+import Cheetah.Filters
+
+import unittest_local_copy as unittest
+
+class BasicMarkdownFilterTest(unittest.TestCase):
+ '''
+ Test that our markdown filter works
+ '''
+ def test_BasicHeader(self):
+ template = '''
+#from Cheetah.Filters import Markdown
+#transform Markdown
+$foo
+
+Header
+======
+ '''
+ expected = '''<p>bar</p>
+<h1>Header</h1>'''
+ try:
+ template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}])
+ template = str(template)
+ assert template == expected
+ except Exception, ex:
+ if ex.__class__.__name__ == 'MarkdownException' and sys.version_info[0] == 2 and sys.version_info[1] < 5:
+ print '>>> NOTE: Support for the Markdown filter will be broken for you. Markdown says: %s' % ex
+ return
+ raise
+
+
+class BasicCodeHighlighterFilterTest(unittest.TestCase):
+ '''
+ Test that our code highlighter filter works
+ '''
+ def test_Python(self):
+ template = '''
+#from Cheetah.Filters import CodeHighlighter
+#transform CodeHighlighter
+
+def foo(self):
+ return '$foo'
+ '''
+ template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}])
+ template = str(template)
+ assert template, (template, 'We should have some content here...')
+
+ def test_Html(self):
+ template = '''
+#from Cheetah.Filters import CodeHighlighter
+#transform CodeHighlighter
+
+<html><head></head><body>$foo</body></html>
+ '''
+ template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}])
+ template = str(template)
+ assert template, (template, 'We should have some content here...')
+
+
+if __name__ == '__main__':
+ unittest.main()