aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWichert Akkerman <wichert@wiggy.net>2014-08-26 13:39:52 +0200
committerWichert Akkerman <wichert@wiggy.net>2014-08-26 13:39:52 +0200
commit28a3f3177aa9d6d586071bf0c9b6958cb631fb2b (patch)
treebd113a310cf768130ed2e9c49d162fc8eb21036c /test
parente3806adeb325eeef3c53830a4dcb5321ef6299a4 (diff)
downloadexternal_python_mako-28a3f3177aa9d6d586071bf0c9b6958cb631fb2b.tar.gz
external_python_mako-28a3f3177aa9d6d586071bf0c9b6958cb631fb2b.tar.bz2
external_python_mako-28a3f3177aa9d6d586071bf0c9b6958cb631fb2b.zip
Use new lingua extractor API
This gives a saner way to call into lingua's Python extractor.
Diffstat (limited to 'test')
-rw-r--r--test/ext/test_linguaplugin.py46
1 files changed, 35 insertions, 11 deletions
diff --git a/test/ext/test_linguaplugin.py b/test/ext/test_linguaplugin.py
index 841f206..55b3ba1 100644
--- a/test/ext/test_linguaplugin.py
+++ b/test/ext/test_linguaplugin.py
@@ -1,7 +1,7 @@
-import io
-import mock
-import unittest
+import os
from mako.ext.linguaplugin import LinguaMakoExtractor
+from lingua.extractors import register_extractors
+from .. import TemplateTest, template_base
class MockOptions:
@@ -9,11 +9,35 @@ class MockOptions:
domain = None
-class Test_LinguaMakoExtractor(unittest.TestCase):
- def test_parse_python_expression(self):
- plugin = LinguaMakoExtractor()
- plugin.options = MockOptions()
- plugin.filename = 'dummy.mako'
- input = io.BytesIO(b'<p>${_("Message")}</p>')
- messages = list(plugin.process_file(input))
- self.assertEqual(len(messages), 1)
+class ExtractMakoTestCase(TemplateTest):
+ def test_extract(self):
+ register_extractors()
+ plugin = LinguaMakoExtractor({'comment-tags': 'TRANSLATOR'})
+ messages = list(plugin(os.path.join(template_base, 'gettext.mako'), MockOptions()))
+ msgids = [(m.msgid, m.msgid_plural) for m in messages]
+ self.assertEqual(
+ msgids,
+ [
+ ('Page arg 1', None),
+ ('Page arg 2', None),
+ ('Begin', None),
+ ('Hi there!', None),
+ ('Hello', None),
+ ('Welcome', None),
+ ('Yo', None),
+ ('The', None),
+ ('bunny', 'bunnies'),
+ ('Goodbye', None),
+ ('Babel', None),
+ ('hella', 'hellas'),
+ ('The', None),
+ ('bunny', 'bunnies'),
+ ('Goodbye, really!', None),
+ ('P.S. byebye', None),
+ ('Top', None),
+ (u'foo', None),
+ ('hoho', None),
+ (u'bar', None),
+ ('Inside a p tag', None),
+ ('Later in a p tag', None),
+ ('No action at a distance.', None)])