Mercurial > babel > mirror
comparison babel/messages/tests/pofile.py @ 106:2cd83f77cc98 trunk
Fix for #16: the header message (`msgid = ""`) is now treated specially by `read_po` and `Catalog`.
author | cmlenz |
---|---|
date | Thu, 14 Jun 2007 09:49:00 +0000 |
parents | c62b68a0b65e |
children | 5d32098d8352 |
comparison
equal
deleted
inserted
replaced
105:c62b68a0b65e | 106:2cd83f77cc98 |
---|---|
16 from StringIO import StringIO | 16 from StringIO import StringIO |
17 import unittest | 17 import unittest |
18 | 18 |
19 from babel.messages.catalog import Catalog | 19 from babel.messages.catalog import Catalog |
20 from babel.messages import pofile | 20 from babel.messages import pofile |
21 | |
22 | |
23 class ReadPoTestCase(unittest.TestCase): | |
24 | |
25 def test_read_multiline(self): | |
26 buf = StringIO(r'''msgid "" | |
27 "Here's some text that\n" | |
28 "includesareallylongwordthatmightbutshouldnt" | |
29 " throw us into an infinite " | |
30 "loop\n" | |
31 msgstr ""''') | |
32 catalog = pofile.read_po(buf) | |
33 self.assertEqual(1, len(catalog)) | |
34 message = list(catalog)[1] | |
35 self.assertEqual("Here's some text that\nincludesareallylongwordthat" | |
36 "mightbutshouldnt throw us into an infinite loop\n", | |
37 message.id) | |
21 | 38 |
22 | 39 |
23 class WritePoTestCase(unittest.TestCase): | 40 class WritePoTestCase(unittest.TestCase): |
24 | 41 |
25 def test_join_locations(self): | 42 def test_join_locations(self): |
108 | 125 |
109 | 126 |
110 def suite(): | 127 def suite(): |
111 suite = unittest.TestSuite() | 128 suite = unittest.TestSuite() |
112 suite.addTest(doctest.DocTestSuite(pofile)) | 129 suite.addTest(doctest.DocTestSuite(pofile)) |
130 suite.addTest(unittest.makeSuite(ReadPoTestCase)) | |
113 suite.addTest(unittest.makeSuite(WritePoTestCase)) | 131 suite.addTest(unittest.makeSuite(WritePoTestCase)) |
114 return suite | 132 return suite |
115 | 133 |
116 if __name__ == '__main__': | 134 if __name__ == '__main__': |
117 unittest.main(defaultTest='suite') | 135 unittest.main(defaultTest='suite') |