~jonas-drange/ubuntu-start-page/1252899-mobile-friendly

« back to all changes in this revision

Viewing changes to src/Mako-0.1.9/test/babelplugin.py

  • Committer: Matthew Nuzum
  • Date: 2008-04-18 01:58:53 UTC
  • Revision ID: matthew.nuzum@canonical.com-20080418015853-2b8rf979z2c2exxl
adding files

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
 
 
3
try:
 
4
    import babel
 
5
 
 
6
    import os
 
7
    from mako.ext.babelplugin import extract
 
8
 
 
9
    class ExtractMakoTestCase(unittest.TestCase):
 
10
        def test_extract(self):
 
11
            mako_tmpl = open(os.path.join('test_htdocs', 'gettext.mako'))
 
12
            messages = list(extract(mako_tmpl, {'_': None, 'gettext': None,
 
13
                                                'ungettext': (1, 2)},
 
14
                                    ['TRANSLATOR:'], {}))
 
15
            expected = \
 
16
                [(1, '_', u'Page arg 1', []),
 
17
                 (1, '_', u'Page arg 2', []),
 
18
                 (10, 'gettext', u'Begin', []),
 
19
                 (14, '_', u'Hi there!', [u'Hi there!']),
 
20
                 (19, '_', u'Hello', []),
 
21
                 (22, '_', u'Welcome', []),
 
22
                 (25, '_', u'Yo', []),
 
23
                 (36, '_', u'The', [u'Ensure so and', u'so, thanks']),
 
24
                 (36, 'ungettext', (u'bunny', u'bunnies', None), []),
 
25
                 (41, '_', u'Goodbye', [u'Good bye']),
 
26
                 (44, '_', u'Babel', []),
 
27
                 (45, 'ungettext', (u'hella', u'hellas', None), []),
 
28
                 (62, '_', u'Goodbye, really!', [u'HTML comment']),
 
29
                 (65, '_', u'P.S. byebye', []),
 
30
                 (71, '_', u'Top', [])]
 
31
            self.assertEqual(expected, messages)
 
32
 
 
33
except ImportError:
 
34
    import warnings
 
35
    warnings.warn('babel not installed: skipping babelplugin test',
 
36
                  RuntimeWarning, 1)
 
37
 
 
38
if __name__ == '__main__':
 
39
    unittest.main()