root/galaxy-central/eggs/Cheetah-2.2.2-py2.6-macosx-10.6-universal-ucs2.egg/Cheetah/Tests/Filters.py

リビジョン 3, 1.9 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1#!/usr/bin/env python
2
3import sys
4
5import Cheetah.Template
6import Cheetah.Filters
7
8import unittest_local_copy as unittest
9
10majorVer, minorVer = sys.version_info[0], sys.version_info[1]
11versionTuple = (majorVer, minorVer)
12
13class 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
23Header
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
39class 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
48def 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
67if __name__ == '__main__':
68    unittest.main()
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。