| 1 | import unittest |
| 2 | import Cheetah.Template |
| 3 | import Cheetah.Filters |
| 4 | |
| 5 | |
| 6 | class BasicMarkdownFilterTest(unittest.TestCase): |
| 7 | ''' |
| 8 | Test that our markdown filter works |
| 9 | ''' |
| 10 | def test_BasicHeader(self): |
| 11 | template = ''' |
| 12 | #from Cheetah.Filters import Markdown |
| 13 | #transform Markdown |
| 14 | $foo |
| 15 | |
| 16 | Header |
| 17 | ====== |
| 18 | ''' |
| 19 | expected = '''<p>bar</p> |
| 20 | <h1>Header</h1>''' |
| 21 | try: |
| 22 | template = Cheetah.Template.Template( |
| 23 | template, searchList=[{'foo': 'bar'}]) |
| 24 | template = str(template) |
| 25 | assert template == expected |
| 26 | except ImportError as ex: |
| 27 | print('>>> We probably failed to import markdown, bummer %s' % ex) |
| 28 | return |
| 29 | except Exception: |
| 30 | raise |
| 31 | |
| 32 | |
| 33 | class BasicCodeHighlighterFilterTest(unittest.TestCase): |
| 34 | ''' |
| 35 | Test that our code highlighter filter works |
| 36 | ''' |
| 37 | def test_Python(self): |
| 38 | template = ''' |
| 39 | #from Cheetah.Filters import CodeHighlighter |
| 40 | #transform CodeHighlighter |
| 41 | |
| 42 | def foo(self): |
| 43 | return '$foo' |
| 44 | ''' |
| 45 | template = Cheetah.Template.Template( |
| 46 | template, searchList=[{'foo': 'bar'}]) |
| 47 | template = str(template) |
| 48 | assert template, (template, 'We should have some content here...') |
| 49 | |
| 50 | def test_Html(self): |
| 51 | template = ''' |
| 52 | #from Cheetah.Filters import CodeHighlighter |
| 53 | #transform CodeHighlighter |
| 54 | |
| 55 | <html><head></head><body>$foo</body></html> |
| 56 | ''' |
| 57 | template = Cheetah.Template.Template( |
| 58 | template, searchList=[{'foo': 'bar'}]) |
| 59 | template = str(template) |
| 60 | assert template, (template, 'We should have some content here...') |