diff options
author | Wichert Akkerman <wichert@wiggy.net> | 2014-08-26 11:48:19 +0200 |
---|---|---|
committer | Wichert Akkerman <wichert@wiggy.net> | 2014-08-26 11:48:19 +0200 |
commit | 5fbd12cce96df6eecd4a513d74b1244a0a49e99d (patch) | |
tree | ab256092ed7e3b18af4042abae922003c7314aaa /test | |
parent | a394b7bae9c5a2a9618973df85dccacbbb7b933d (diff) | |
download | external_python_mako-5fbd12cce96df6eecd4a513d74b1244a0a49e99d.tar.gz external_python_mako-5fbd12cce96df6eecd4a513d74b1244a0a49e99d.tar.bz2 external_python_mako-5fbd12cce96df6eecd4a513d74b1244a0a49e99d.zip |
Merge babel test files.
Diffstat (limited to 'test')
-rw-r--r-- | test/ext/test_babelplugin.py | 37 | ||||
-rw-r--r-- | test/test_babelplugin.py | 49 |
2 files changed, 36 insertions, 50 deletions
diff --git a/test/ext/test_babelplugin.py b/test/ext/test_babelplugin.py index 1dacf33..4f17ad9 100644 --- a/test/ext/test_babelplugin.py +++ b/test/ext/test_babelplugin.py @@ -1,7 +1,8 @@ import io -import mock +import os import unittest from mako.ext.babelplugin import extract +from .. import TemplateTest, template_base class Test_extract(unittest.TestCase): @@ -25,3 +26,37 @@ class Test_extract(unittest.TestCase): self.assertEqual( messages, [(4, '_', u'Message', [u'TRANSLATORS: This is a comment.'])]) + + +class ExtractMakoTestCase(TemplateTest): + def test_extract(self): + mako_tmpl = open(os.path.join(template_base, 'gettext.mako')) + messages = list(extract(mako_tmpl, {'_': None, 'gettext': None, + 'ungettext': (1, 2)}, + ['TRANSLATOR:'], {})) + expected = \ + [(1, '_', 'Page arg 1', []), + (1, '_', 'Page arg 2', []), + (10, 'gettext', 'Begin', []), + (14, '_', 'Hi there!', ['TRANSLATOR: Hi there!']), + (19, '_', 'Hello', []), + (22, '_', 'Welcome', []), + (25, '_', 'Yo', []), + (36, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), + (36, 'ungettext', ('bunny', 'bunnies', None), []), + (41, '_', 'Goodbye', ['TRANSLATOR: Good bye']), + (44, '_', 'Babel', []), + (45, 'ungettext', ('hella', 'hellas', None), []), + (62, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), + (62, 'ungettext', ('bunny', 'bunnies', None), []), + (68, '_', 'Goodbye, really!', ['TRANSLATOR: HTML comment']), + (71, '_', 'P.S. byebye', []), + (77, '_', 'Top', []), + (83, '_', 'foo', []), + (83, '_', 'hoho', []), + (85, '_', 'bar', []), + (92, '_', 'Inside a p tag', ['TRANSLATOR: <p> tag is ok?']), + (95, '_', 'Later in a p tag', ['TRANSLATOR: also this']), + (99, '_', 'No action at a distance.', []), + ] + self.assertEqual(expected, messages) diff --git a/test/test_babelplugin.py b/test/test_babelplugin.py deleted file mode 100644 index 023433d..0000000 --- a/test/test_babelplugin.py +++ /dev/null @@ -1,49 +0,0 @@ - -from test import TemplateTest, template_base, skip_if - -try: - import babel -except: - babel = None - -if babel is not None: - from mako.ext.babelplugin import extract - -import os - - -class ExtractMakoTestCase(TemplateTest): - - @skip_if(lambda: not babel, 'babel not installed: skipping babelplugin test') - def test_extract(self): - mako_tmpl = open(os.path.join(template_base, 'gettext.mako')) - messages = list(extract(mako_tmpl, {'_': None, 'gettext': None, - 'ungettext': (1, 2)}, - ['TRANSLATOR:'], {})) - expected = \ - [(1, '_', 'Page arg 1', []), - (1, '_', 'Page arg 2', []), - (10, 'gettext', 'Begin', []), - (14, '_', 'Hi there!', ['TRANSLATOR: Hi there!']), - (19, '_', 'Hello', []), - (22, '_', 'Welcome', []), - (25, '_', 'Yo', []), - (36, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), - (36, 'ungettext', ('bunny', 'bunnies', None), []), - (41, '_', 'Goodbye', ['TRANSLATOR: Good bye']), - (44, '_', 'Babel', []), - (45, 'ungettext', ('hella', 'hellas', None), []), - (62, '_', 'The', ['TRANSLATOR: Ensure so and', 'so, thanks']), - (62, 'ungettext', ('bunny', 'bunnies', None), []), - (68, '_', 'Goodbye, really!', ['TRANSLATOR: HTML comment']), - (71, '_', 'P.S. byebye', []), - (77, '_', 'Top', []), - (83, '_', 'foo', []), - (83, '_', 'hoho', []), - (85, '_', 'bar', []), - (92, '_', 'Inside a p tag', ['TRANSLATOR: <p> tag is ok?']), - (95, '_', 'Later in a p tag', ['TRANSLATOR: also this']), - (99, '_', 'No action at a distance.', []), - ] - self.assertEqual(expected, messages) - |