annotate babel/catalog/tests/extract.py @ 38:06b876ed5501

Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
author cmlenz
date Mon, 04 Jun 2007 21:30:52 +0000
parents 29ef15a6fd75
children
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
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
14 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
15 from StringIO import StringIO
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
16 import unittest
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
17
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
18 from babel.catalog import extract
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
19
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
20
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
21 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
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 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
24 buf = StringIO("msg = _(u'Foo Bar')")
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
25 messages = list(extract.extract_python(buf, ('_',), {}))
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
26 self.assertEqual('Foo Bar', messages[0][2])
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
27
06b876ed5501 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 14
diff changeset
28
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
29 def suite():
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
30 suite = unittest.TestSuite()
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
31 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
32 suite.addTest(unittest.makeSuite(ExtractPythonTestCase))
3
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
33 return suite
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
34
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
35 if __name__ == '__main__':
e9eaddab598e Import of initial code base.
cmlenz
parents:
diff changeset
36 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software