annotate genshi/filters/tests/i18n.py @ 595:6d51c8df5d5a stable-0.4.x

Ported [708] to 0.4.x branch.
author cmlenz
date Mon, 13 Aug 2007 23:04:50 +0000
parents d8ccbef91504
children 2c52ec2c9d7e
rev   line source
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
2 #
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
3 # Copyright (C) 2007 Edgewall Software
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
4 # All rights reserved.
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
5 #
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
8 # are also available at http://genshi.edgewall.org/wiki/License.
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
9 #
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://genshi.edgewall.org/log/.
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
13
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
14 import doctest
486
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
15 from StringIO import StringIO
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
16 import unittest
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
17
486
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
18 from genshi.template import MarkupTemplate
532
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
19 from genshi.filters.i18n import Translator, extract
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
20
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
21
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
22 class TranslatorTestCase(unittest.TestCase):
486
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
23
595
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
24 def test_extract_without_text(self):
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
25 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
26 <p title="Bar">Foo</p>
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
27 ${ngettext("Singular", "Plural", num)}
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
28 </html>""")
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
29 translator = Translator(extract_text=False)
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
30 messages = list(translator.extract(tmpl.stream))
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
31 self.assertEqual(1, len(messages))
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
32 self.assertEqual((3, 'ngettext', (u'Singular', u'Plural')), messages[0])
6d51c8df5d5a Ported [708] to 0.4.x branch.
cmlenz
parents: 551
diff changeset
33
486
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
34 def test_extract_plural_form(self):
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
35 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
36 ${ngettext("Singular", "Plural", num)}
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
37 </html>""")
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
38 translator = Translator()
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
39 messages = list(translator.extract(tmpl.stream))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
40 self.assertEqual(1, len(messages))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
41 self.assertEqual((2, 'ngettext', (u'Singular', u'Plural')), messages[0])
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
42
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
43 def test_extract_included_attribute_text(self):
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
44 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
45 <span title="Foo"></span>
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
46 </html>""")
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
47 translator = Translator()
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
48 messages = list(translator.extract(tmpl.stream))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
49 self.assertEqual(1, len(messages))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
50 self.assertEqual((2, None, u'Foo'), messages[0])
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
51
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
52 def test_extract_attribute_expr(self):
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
53 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
54 <input type="submit" value="${_('Save')}" />
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
55 </html>""")
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
56 translator = Translator()
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
57 messages = list(translator.extract(tmpl.stream))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
58 self.assertEqual(1, len(messages))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
59 self.assertEqual((2, '_', u'Save'), messages[0])
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
60
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
61 def test_extract_non_included_attribute_interpolated(self):
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
62 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
63 <a href="#anchor_${num}">Foo</a>
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
64 </html>""")
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
65 translator = Translator()
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
66 messages = list(translator.extract(tmpl.stream))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
67 self.assertEqual(1, len(messages))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
68 self.assertEqual((2, None, u'Foo'), messages[0])
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
69
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
70 def test_extract_text_from_sub(self):
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
71 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
72 <py:if test="foo">Foo</py:if>
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
73 </html>""")
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
74 translator = Translator()
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
75 messages = list(translator.extract(tmpl.stream))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
76 self.assertEqual(1, len(messages))
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
77 self.assertEqual((2, None, u'Foo'), messages[0])
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
78
523
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
79 def test_ignore_tag_with_fixed_xml_lang(self):
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
80 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
81 <p xml:lang="en">(c) 2007 Edgewall Software</p>
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
82 </html>""")
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
83 translator = Translator()
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
84 messages = list(translator.extract(tmpl.stream))
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
85 self.assertEqual(0, len(messages))
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
86
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
87 def test_extract_tag_with_variable_xml_lang(self):
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
88 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
89 <p xml:lang="${lang}">(c) 2007 Edgewall Software</p>
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
90 </html>""")
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
91 translator = Translator()
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
92 messages = list(translator.extract(tmpl.stream))
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
93 self.assertEqual(1, len(messages))
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
94 self.assertEqual((2, None, u'(c) 2007 Edgewall Software'), messages[0])
5b59e911e6c3 Ported [626] to 0.4.x branch.
cmlenz
parents: 486
diff changeset
95
536
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
96 def test_ignore_attribute_with_expression(self):
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
97 tmpl = MarkupTemplate("""<html xmlns:py="http://genshi.edgewall.org/">
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
98 <input type="submit" value="Reply" title="Reply to comment $num" />
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
99 </html>""")
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
100 translator = Translator()
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
101 messages = list(translator.extract(tmpl.stream))
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
102 self.assertEqual(0, len(messages))
a40ad8334f0f Ported [643] to 0.4.x branch.
cmlenz
parents: 532
diff changeset
103
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
104
532
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
105 class ExtractTestCase(unittest.TestCase):
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
106
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
107 def test_markup_template_extraction(self):
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
108 buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
109 <head>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
110 <title>Example</title>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
111 </head>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
112 <body>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
113 <h1>Example</h1>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
114 <p>${_("Hello, %(name)s") % dict(name=username)}</p>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
115 <p>${ngettext("You have %d item", "You have %d items", num)}</p>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
116 </body>
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
117 </html>""")
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
118 results = list(extract(buf, ['_', 'ngettext'], [], {}))
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
119 self.assertEqual([
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
120 (3, None, u'Example', []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
121 (6, None, u'Example', []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
122 (7, '_', u'Hello, %(name)s', []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
123 (8, 'ngettext', (u'You have %d item', u'You have %d items'), []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
124 ], results)
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
125
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
126 def test_text_template_extraction(self):
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
127 buf = StringIO("""${_("Dear %(name)s") % {'name': name}},
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
128
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
129 ${ngettext("Your item:", "Your items", len(items))}
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
130 #for item in items
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
131 * $item
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
132 #end
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
133
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
134 All the best,
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
135 Foobar""")
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
136 results = list(extract(buf, ['_', 'ngettext'], [], {
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
137 'template_class': 'genshi.template:TextTemplate'
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
138 }))
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
139 self.assertEqual([
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
140 (1, '_', u'Dear %(name)s', []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
141 (3, 'ngettext', (u'Your item:', u'Your items'), []),
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
142 (7, None, u'All the best,\n Foobar', [])
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
143 ], results)
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
144
551
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
145 def test_extraction_inside_ignored_tags(self):
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
146 buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
147 <script type="text/javascript">
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
148 $('#llist').tabs({
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
149 remote: true,
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
150 spinner: "${_('Please wait...')}"
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
151 });
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
152 </script>
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
153 </html>""")
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
154 results = list(extract(buf, ['_'], [], {}))
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
155 self.assertEqual([
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
156 (5, '_', u'Please wait...', []),
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
157 ], results)
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
158
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
159 def test_extraction_inside_ignored_tags_with_directives(self):
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
160 buf = StringIO("""<html xmlns:py="http://genshi.edgewall.org/">
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
161 <script type="text/javascript">
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
162 <py:if test="foobar">
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
163 alert("This shouldn't be extracted");
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
164 </py:if>
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
165 </script>
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
166 </html>""")
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
167 self.assertEqual([], list(extract(buf, ['_'], [], {})))
d8ccbef91504 Ported [658:659] to 0.4.x branch.
cmlenz
parents: 536
diff changeset
168
532
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
169
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
170 def suite():
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
171 suite = unittest.TestSuite()
532
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
172 suite.addTests(doctest.DocTestSuite(Translator.__module__))
486
6a48853a2e36 Ported [585] to 0.4.x.
cmlenz
parents: 446
diff changeset
173 suite.addTest(unittest.makeSuite(TranslatorTestCase, 'test'))
532
f9ad40cae2f7 Ported [634:637] to 0.4.x branch.
cmlenz
parents: 523
diff changeset
174 suite.addTest(unittest.makeSuite(ExtractTestCase, 'test'))
446
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
175 return suite
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
176
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
177 if __name__ == '__main__':
90f5908cd10a Add basic I18n/L10n functionality, based on GenshiRecipes/Localization.
cmlenz
parents:
diff changeset
178 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software