annotate babel/catalog/tests/extract.py @ 36:cfd15b7921f9 trunk

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 e6ba3e878b10
children
rev   line source
1
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
1 # -*- coding: utf-8 -*-
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
2 #
12
e6ba3e878b10 * Removed pkg_resources/setuptools requirement from various places.
cmlenz
parents: 1
diff changeset
3 # Copyright (C) 2007 Edgewall Software
1
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
4 # All rights reserved.
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
5 #
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
6 # This software is licensed as described in the file COPYING, which
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
7 # you should have received as part of this distribution. The terms
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
8 # are also available at http://babel.edgewall.org/wiki/License.
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
9 #
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
10 # This software consists of voluntary contributions made by many
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
11 # individuals. For the exact contribution history, see the revision
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
12 # history and logs, available at http://babel.edgewall.org/log/.
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
13
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
14 import doctest
36
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
15 from StringIO import StringIO
1
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
16 import unittest
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
17
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
18 from babel.catalog import extract
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
19
36
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
20
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
21 class ExtractPythonTestCase(unittest.TestCase):
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
22
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
23 def test_unicode_string_arg(self):
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
24 buf = StringIO("msg = _(u'Foo Bar')")
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
25 messages = list(extract.extract_python(buf, ('_',), {}))
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
26 self.assertEqual('Foo Bar', messages[0][2])
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
27
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
28
1
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
29 def suite():
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
30 suite = unittest.TestSuite()
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
31 suite.addTest(doctest.DocTestSuite(extract))
36
cfd15b7921f9 Fix for #8: fix extraction of strings from Python source using prefixes ('u' or 'r') or triple quotes.
cmlenz
parents: 12
diff changeset
32 suite.addTest(unittest.makeSuite(ExtractPythonTestCase))
1
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
33 return suite
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
34
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
35 if __name__ == '__main__':
7870274479f5 Import of initial code base.
cmlenz
parents:
diff changeset
36 unittest.main(defaultTest='suite')
Copyright (C) 2012-2017 Edgewall Software