annotate babel/messages/tests/extract.py @ 225:81c21bbd812f

fix skipping of class definitions without parens fixes #55
author pjenvey
date Wed, 18 Jul 2007 20:49:12 +0000
parents 9d0a19b4518b
children 043201653d56
rev   line source
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
2 #
14
29ef15a6fd75 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents: 3
diff changeset
3 # Copyright (C) 2007 Edgewall Software
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
4 # All rights reserved.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
5 #
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
9 #
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
13
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
14 import codecs
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
15 import doctest
38
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
16 from StringIO import StringIO
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
17 import sys
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
18 import unittest
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
19
56
27d55a07c897 Rename the `babel.catalog` package to `babel.messages` for consistency with the other package names.
cmlenz
parents: 38
diff changeset
20 from babel.messages import extract
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
21
38
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
22
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
23 class ExtractPythonTestCase(unittest.TestCase):
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
24
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
25 def test_nested_calls(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
26 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
27 msg1 = _(i18n_arg.replace(r'\"', '"'))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
28 msg2 = ungettext(i18n_arg.replace(r'\"', '"'), multi_arg.replace(r'\"', '"'), 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
29 msg3 = ungettext("Babel", multi_arg.replace(r'\"', '"'), 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
30 msg4 = ungettext(i18n_arg.replace(r'\"', '"'), "Babels", 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
31 msg5 = ungettext('bunny', 'bunnies', random.randint(1, 2))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
32 msg6 = ungettext(arg0, 'bunnies', random.randint(1, 2))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
33 msg7 = _(hello.there)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
34 msg8 = gettext('Rabbit')
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
35 msg9 = dgettext('wiki', model.addPage())
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
36 msg10 = dngettext(getDomain(), 'Page', 'Pages', 3)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
37 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
38 messages = list(extract.extract_python(buf,
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
39 extract.DEFAULT_KEYWORDS.keys(),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
40 [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
41 self.assertEqual([
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
42 (1, '_', None, []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
43 (2, 'ungettext', (None, None, None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
44 (3, 'ungettext', (u'Babel', None, None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
45 (4, 'ungettext', (None, u'Babels', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
46 (5, 'ungettext', (u'bunny', u'bunnies', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
47 (6, 'ungettext', (None, u'bunnies', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
48 (7, '_', None, []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
49 (8, 'gettext', u'Rabbit', []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
50 (9, 'dgettext', (u'wiki', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
51 (10, 'dngettext', (None, u'Page', u'Pages', None), [])],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
52 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
53
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
54 def test_nested_comments(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
55 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
56 msg = ngettext('pylon', # TRANSLATORS: shouldn't be
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
57 'pylons', # TRANSLATORS: seeing this
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
58 count)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
59 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
60 messages = list(extract.extract_python(buf, ('ngettext',),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
61 ['TRANSLATORS:'], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
62 self.assertEqual([(1, 'ngettext', (u'pylon', u'pylons', None), [])],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
63 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
64
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
65 def test_declarations(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
66 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
67 class gettext(object):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
68 pass
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
69 def render_body(context,x,y=_('Page arg 1'),z=_('Page arg 2'),**pageargs):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
70 pass
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
71 def ngettext(y='arg 1',z='arg 2',**pageargs):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
72 pass
225
81c21bbd812f fix skipping of class definitions without parens
pjenvey
parents: 224
diff changeset
73 class Meta:
81c21bbd812f fix skipping of class definitions without parens
pjenvey
parents: 224
diff changeset
74 verbose_name = _('log entry')
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
75 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
76 messages = list(extract.extract_python(buf,
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
77 extract.DEFAULT_KEYWORDS.keys(),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
78 [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
79 self.assertEqual([(3, '_', u'Page arg 1', []),
225
81c21bbd812f fix skipping of class definitions without parens
pjenvey
parents: 224
diff changeset
80 (3, '_', u'Page arg 2', []),
81c21bbd812f fix skipping of class definitions without parens
pjenvey
parents: 224
diff changeset
81 (8, '_', u'log entry', [])],
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
82 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
83
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
84 def test_multiline(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
85 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
86 msg1 = ngettext('pylon',
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
87 'pylons', count)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
88 msg2 = ngettext('elvis',
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
89 'elvises',
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
90 count)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
91 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
92 messages = list(extract.extract_python(buf, ('ngettext',), [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
93 self.assertEqual([(1, 'ngettext', (u'pylon', u'pylons', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
94 (3, 'ngettext', (u'elvis', u'elvises', None), [])],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
95 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
96
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
97 def test_triple_quoted_strings(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
98 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
99 msg1 = _('''pylons''')
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
100 msg2 = ngettext(r'''elvis''', \"\"\"elvises\"\"\", count)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
101 msg2 = ngettext(\"\"\"elvis\"\"\", 'elvises', count)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
102 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
103 messages = list(extract.extract_python(buf,
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
104 extract.DEFAULT_KEYWORDS.keys(),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
105 [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
106 self.assertEqual([(1, '_', (u'pylons'), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
107 (2, 'ngettext', (u'elvis', u'elvises', None), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
108 (3, 'ngettext', (u'elvis', u'elvises', None), [])],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
109 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
110
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
111 def test_multiline_strings(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
112 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
113 _('''This module provides internationalization and localization
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
114 support for your Python programs by providing an interface to the GNU
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
115 gettext message catalog library.''')
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
116 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
117 messages = list(extract.extract_python(buf,
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
118 extract.DEFAULT_KEYWORDS.keys(),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
119 [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
120 self.assertEqual(
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
121 [(1, '_',
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
122 u'This module provides internationalization and localization\n'
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
123 'support for your Python programs by providing an interface to '
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
124 'the GNU\ngettext message catalog library.', [])],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
125 messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
126
38
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
127 def test_unicode_string_arg(self):
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
128 buf = StringIO("msg = _(u'Foo Bar')")
85
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
129 messages = list(extract.extract_python(buf, ('_',), [], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
130 self.assertEqual(u'Foo Bar', messages[0][2])
38
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
131
85
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
132 def test_comment_tag(self):
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
133 buf = StringIO("""
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
134 # NOTE: A translation comment
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
135 msg = _(u'Foo Bar')
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
136 """)
93
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
137 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
138 self.assertEqual(u'Foo Bar', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
139 self.assertEqual([u'A translation comment'], messages[0][3])
85
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
140
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
141 def test_comment_tag_multiline(self):
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
142 buf = StringIO("""
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
143 # NOTE: A translation comment
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
144 # with a second line
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
145 msg = _(u'Foo Bar')
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
146 """)
93
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
147 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
148 self.assertEqual(u'Foo Bar', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
149 self.assertEqual([u'A translation comment', u'with a second line'],
85
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
150 messages[0][3])
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
151
87
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
152 def test_translator_comments_with_previous_non_translator_comments(self):
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
153 buf = StringIO("""
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
154 # This shouldn't be in the output
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
155 # because it didn't start with a comment tag
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
156 # NOTE: A translation comment
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
157 # with a second line
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
158 msg = _(u'Foo Bar')
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
159 """)
93
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
160 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
161 self.assertEqual(u'Foo Bar', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
162 self.assertEqual([u'A translation comment', u'with a second line'],
87
f140be344563 Fixed de-pluralization bug introduced in [85] regarding the extraction of translator comments.
palgarvio
parents: 85
diff changeset
163 messages[0][3])
85
e10f82c1d4c4 Add unit tests for extracting translator comments from python sources.
cmlenz
parents: 82
diff changeset
164
93
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
165 def test_comment_tags_not_on_start_of_comment(self):
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
166 buf = StringIO("""
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
167 # This shouldn't be in the output
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
168 # because it didn't start with a comment tag
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
169 # do NOTE: this will no be a translation comment
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
170 # NOTE: This one will be
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
171 msg = _(u'Foo Bar')
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
172 """)
30ed605cff51 Changed translator comments extraction behaviour in python source code. Match is now true only if the TAG is on the start of the comment. The TAG will also be stripped from the comment. Added a unittest which tests this.
palgarvio
parents: 87
diff changeset
173 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
174 self.assertEqual(u'Foo Bar', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
175 self.assertEqual([u'This one will be'], messages[0][3])
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
176
94
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
177 def test_multiple_comment_tags(self):
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
178 buf = StringIO("""
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
179 # NOTE1: A translation comment for tag1
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
180 # with a second line
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
181 msg = _(u'Foo Bar1')
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
182
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
183 # NOTE2: A translation comment for tag2
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
184 msg = _(u'Foo Bar2')
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
185 """)
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
186 messages = list(extract.extract_python(buf, ('_',),
655b03680d84 Fixed bug introduced in [92], bad use of `lstrip()`. Added a unittest to test multiple translator comment tags.
palgarvio
parents: 93
diff changeset
187 ['NOTE1:', 'NOTE2:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
188 self.assertEqual(u'Foo Bar1', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
189 self.assertEqual([u'A translation comment for tag1',
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
190 u'with a second line'], messages[0][3])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
191 self.assertEqual(u'Foo Bar2', messages[1][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
192 self.assertEqual([u'A translation comment for tag2'], messages[1][3])
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
193
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
194 def test_two_succeeding_comments(self):
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
195 buf = StringIO("""
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
196 # NOTE: one
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
197 # NOTE: two
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
198 msg = _(u'Foo Bar')
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
199 """)
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
200 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
201 self.assertEqual(u'Foo Bar', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
202 self.assertEqual([u'one', u'NOTE: two'], messages[0][3])
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
203
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
204 def test_invalid_translator_comments(self):
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
205 buf = StringIO("""
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
206 # NOTE: this shouldn't apply to any messages
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
207 hello = 'there'
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
208
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
209 msg = _(u'Foo Bar')
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
210 """)
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
211 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
212 self.assertEqual(u'Foo Bar', messages[0][2])
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
213 self.assertEqual([], messages[0][3])
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
214
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
215 def test_invalid_translator_comments2(self):
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
216 buf = StringIO("""
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
217 # NOTE: Hi!
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
218 hithere = _('Hi there!')
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
219
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
220 # NOTE: you should not be seeing this in the .po
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
221 rows = [[v for v in range(0,10)] for row in range(0,10)]
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
222
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
223 # this (NOTE:) should not show up either
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
224 hello = _('Hello')
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
225 """)
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
226 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
227 self.assertEqual(u'Hi there!', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
228 self.assertEqual([u'Hi!'], messages[0][3])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
229 self.assertEqual(u'Hello', messages[1][2])
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
230 self.assertEqual([], messages[1][3])
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
231
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
232 def test_invalid_translator_comments3(self):
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
233 buf = StringIO("""
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
234 # NOTE: Hi,
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
235
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
236 # there!
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
237 hithere = _('Hi there!')
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
238 """)
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
239 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
240 self.assertEqual(u'Hi there!', messages[0][2])
95
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
241 self.assertEqual([], messages[0][3])
979dc0d7bc5d Commiting patch provided by pjenvey: Translator comments don't apply unless they immediately preceed the message.
palgarvio
parents: 94
diff changeset
242
166
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
243 def test_utf8_message(self):
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
244 buf = StringIO("""
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
245 # NOTE: hello
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
246 msg = _('Bonjour à tous')
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
247 """)
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
248 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'],
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
249 {'encoding': 'utf-8'}))
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
250 self.assertEqual(u'Bonjour à tous', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
251 self.assertEqual([u'hello'], messages[0][3])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
252
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
253 def test_utf8_message_with_magic_comment(self):
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
254 buf = StringIO("""# -*- coding: utf-8 -*-
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
255 # NOTE: hello
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
256 msg = _('Bonjour à tous')
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
257 """)
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
258 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
259 self.assertEqual(u'Bonjour à tous', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
260 self.assertEqual([u'hello'], messages[0][3])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
261
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
262 def test_utf8_message_with_utf8_bom(self):
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
263 buf = StringIO(codecs.BOM_UTF8 + """
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
264 # NOTE: hello
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
265 msg = _('Bonjour à tous')
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
266 """)
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
267 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
268 self.assertEqual(u'Bonjour à tous', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
269 self.assertEqual([u'hello'], messages[0][3])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
270
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
271 def test_utf8_raw_strings_match_unicode_strings(self):
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
272 buf = StringIO(codecs.BOM_UTF8 + """
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
273 msg = _('Bonjour à tous')
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
274 msgu = _(u'Bonjour à tous')
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
275 """)
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
276 messages = list(extract.extract_python(buf, ('_',), ['NOTE:'], {}))
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
277 self.assertEqual(u'Bonjour à tous', messages[0][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
278 self.assertEqual(messages[0][2], messages[1][2])
0eccbe635dba made the python extractor detect source file encodings from the magic encoding
pjenvey
parents: 95
diff changeset
279
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
280 class ExtractTestCase(unittest.TestCase):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
281
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
282 def test_invalid_filter(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
283 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
284 msg1 = _(i18n_arg.replace(r'\"', '"'))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
285 msg2 = ungettext(i18n_arg.replace(r'\"', '"'), multi_arg.replace(r'\"', '"'), 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
286 msg3 = ungettext("Babel", multi_arg.replace(r'\"', '"'), 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
287 msg4 = ungettext(i18n_arg.replace(r'\"', '"'), "Babels", 2)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
288 msg5 = ungettext('bunny', 'bunnies', random.randint(1, 2))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
289 msg6 = ungettext(arg0, 'bunnies', random.randint(1, 2))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
290 msg7 = _(hello.there)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
291 msg8 = gettext('Rabbit')
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
292 msg9 = dgettext('wiki', model.addPage())
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
293 msg10 = dngettext(domain, 'Page', 'Pages', 3)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
294 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
295 messages = \
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
296 list(extract.extract('python', buf, extract.DEFAULT_KEYWORDS, [],
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
297 {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
298 self.assertEqual([(5, (u'bunny', u'bunnies'), []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
299 (8, u'Rabbit', []),
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
300 (10, (u'Page', u'Pages'), [])], messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
301
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
302 def test_empty_string_msgid(self):
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
303 buf = StringIO("""\
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
304 msg = _('')
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
305 """)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
306 stderr = sys.stderr
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
307 sys.stderr = StringIO()
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
308 try:
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
309 messages = \
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
310 list(extract.extract('python', buf, extract.DEFAULT_KEYWORDS,
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
311 [], {}))
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
312 self.assertEqual([], messages)
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
313 assert 'warning: Empty msgid.' in sys.stderr.getvalue()
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
314 finally:
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
315 sys.stderr = stderr
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
316
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
317 def suite():
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
318 suite = unittest.TestSuite()
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
319 suite.addTest(doctest.DocTestSuite(extract))
38
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
320 suite.addTest(unittest.makeSuite(ExtractPythonTestCase))
224
9d0a19b4518b o extract_python fixes:
pjenvey
parents: 166
diff changeset
321 suite.addTest(unittest.makeSuite(ExtractTestCase))
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
322 return suite
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
323
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
324 if __name__ == '__main__':
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
325 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software