1 | #!/usr/bin/env python |
---|
2 | |
---|
3 | import sys |
---|
4 | |
---|
5 | import Cheetah.Template |
---|
6 | import Cheetah.Filters |
---|
7 | |
---|
8 | import unittest_local_copy as unittest |
---|
9 | |
---|
10 | majorVer, minorVer = sys.version_info[0], sys.version_info[1] |
---|
11 | versionTuple = (majorVer, minorVer) |
---|
12 | |
---|
13 | class BasicMarkdownFilterTest(unittest.TestCase): |
---|
14 | ''' |
---|
15 | Test that our markdown filter works |
---|
16 | ''' |
---|
17 | def test_BasicHeader(self): |
---|
18 | template = ''' |
---|
19 | #from Cheetah.Filters import Markdown |
---|
20 | #transform Markdown |
---|
21 | $foo |
---|
22 | |
---|
23 | Header |
---|
24 | ====== |
---|
25 | ''' |
---|
26 | expected = '''<p>bar</p> |
---|
27 | <h1>Header</h1>''' |
---|
28 | try: |
---|
29 | template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}]) |
---|
30 | template = str(template) |
---|
31 | assert template == expected |
---|
32 | except Exception, ex: |
---|
33 | if ex.__class__.__name__ == 'MarkdownException' and majorVer == 2 and minorVer < 5: |
---|
34 | print '>>> NOTE: Support for the Markdown filter will be broken for you. Markdown says: %s' % ex |
---|
35 | return |
---|
36 | raise |
---|
37 | |
---|
38 | |
---|
39 | class BasicCodeHighlighterFilterTest(unittest.TestCase): |
---|
40 | ''' |
---|
41 | Test that our code highlighter filter works |
---|
42 | ''' |
---|
43 | def test_Python(self): |
---|
44 | template = ''' |
---|
45 | #from Cheetah.Filters import CodeHighlighter |
---|
46 | #transform CodeHighlighter |
---|
47 | |
---|
48 | def foo(self): |
---|
49 | return '$foo' |
---|
50 | ''' |
---|
51 | template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}]) |
---|
52 | template = str(template) |
---|
53 | assert template, (template, 'We should have some content here...') |
---|
54 | |
---|
55 | def test_Html(self): |
---|
56 | template = ''' |
---|
57 | #from Cheetah.Filters import CodeHighlighter |
---|
58 | #transform CodeHighlighter |
---|
59 | |
---|
60 | <html><head></head><body>$foo</body></html> |
---|
61 | ''' |
---|
62 | template = Cheetah.Template.Template(template, searchList=[{'foo' : 'bar'}]) |
---|
63 | template = str(template) |
---|
64 | assert template, (template, 'We should have some content here...') |
---|
65 | |
---|
66 | |
---|
67 | if __name__ == '__main__': |
---|
68 | unittest.main() |
---|