Mercurial > babel > mirror
comparison babel/catalog/tests/pofile.py @ 51:d484eb9a70d5 trunk
Fixed a bug regarding plural msgid's handling when writing the `.pot` file.
Renamed old `write_po` to `write_pot` which is what it actually does and also adds space to the new `write_po`. Changed tests accordingly.
Added support to create new localized catalogs from a catalog template, `write_po`..
author | palgarvio |
---|---|
date | Thu, 07 Jun 2007 22:48:47 +0000 |
parents | b09e90803d1b |
children |
comparison
equal
deleted
inserted
replaced
50:0896af2c49ec | 51:d484eb9a70d5 |
---|---|
24 assert pofile.PYTHON_FORMAT('foo %d bar') | 24 assert pofile.PYTHON_FORMAT('foo %d bar') |
25 assert pofile.PYTHON_FORMAT('foo %s bar') | 25 assert pofile.PYTHON_FORMAT('foo %s bar') |
26 assert pofile.PYTHON_FORMAT('foo %r bar') | 26 assert pofile.PYTHON_FORMAT('foo %r bar') |
27 | 27 |
28 | 28 |
29 class WritePoTestCase(unittest.TestCase): | 29 class WritePotTestCase(unittest.TestCase): |
30 | 30 |
31 def test_join_locations(self): | 31 def test_join_locations(self): |
32 buf = StringIO() | 32 buf = StringIO() |
33 pofile.write_po(buf, [ | 33 pofile.write_pot(buf, [ |
34 ('main.py', 1, None, u'foo', None), | 34 ('main.py', 1, None, u'foo', None), |
35 ('utils.py', 3, None, u'foo', None), | 35 ('utils.py', 3, None, u'foo', None), |
36 ], omit_header=True) | 36 ], omit_header=True) |
37 self.assertEqual('''#: main.py:1 utils.py:3 | 37 self.assertEqual('''#: main.py:1 utils.py:3 |
38 msgid "foo" | 38 msgid "foo" |
44 | 44 |
45 not be removed | 45 not be removed |
46 | 46 |
47 """ | 47 """ |
48 buf = StringIO() | 48 buf = StringIO() |
49 pofile.write_po(buf, [ | 49 pofile.write_pot(buf, [ |
50 ('main.py', 1, None, text, None), | 50 ('main.py', 1, None, text, None), |
51 ], no_location=True, omit_header=True, width=42) | 51 ], no_location=True, omit_header=True, width=42) |
52 self.assertEqual(r'''msgid "" | 52 self.assertEqual(r'''msgid "" |
53 "Here's some text where \n" | 53 "Here's some text where \n" |
54 "white space and line breaks matter, and" | 54 "white space and line breaks matter, and" |
61 def test_wrap_long_lines_with_long_word(self): | 61 def test_wrap_long_lines_with_long_word(self): |
62 text = """Here's some text that | 62 text = """Here's some text that |
63 includesareallylongwordthatmightbutshouldnt throw us into an infinite loop | 63 includesareallylongwordthatmightbutshouldnt throw us into an infinite loop |
64 """ | 64 """ |
65 buf = StringIO() | 65 buf = StringIO() |
66 pofile.write_po(buf, [ | 66 pofile.write_pot(buf, [ |
67 ('main.py', 1, None, text, None), | 67 ('main.py', 1, None, text, None), |
68 ], no_location=True, omit_header=True, width=32) | 68 ], no_location=True, omit_header=True, width=32) |
69 self.assertEqual(r'''msgid "" | 69 self.assertEqual(r'''msgid "" |
70 "Here's some text that\n" | 70 "Here's some text that\n" |
71 "includesareallylongwordthatmightbutshouldnt" | 71 "includesareallylongwordthatmightbutshouldnt" |
76 | 76 |
77 def suite(): | 77 def suite(): |
78 suite = unittest.TestSuite() | 78 suite = unittest.TestSuite() |
79 suite.addTest(doctest.DocTestSuite(pofile)) | 79 suite.addTest(doctest.DocTestSuite(pofile)) |
80 suite.addTest(unittest.makeSuite(PythonFormatFlagTestCase)) | 80 suite.addTest(unittest.makeSuite(PythonFormatFlagTestCase)) |
81 suite.addTest(unittest.makeSuite(WritePoTestCase)) | 81 suite.addTest(unittest.makeSuite(WritePotTestCase)) |
82 return suite | 82 return suite |
83 | 83 |
84 if __name__ == '__main__': | 84 if __name__ == '__main__': |
85 unittest.main(defaultTest='suite') | 85 unittest.main(defaultTest='suite') |