diff 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
line wrap: on
line diff
--- a/babel/messages/tests/pofile.py
+++ b/babel/messages/tests/pofile.py
@@ -20,6 +20,23 @@
 from babel.messages import pofile
 
 
+class ReadPoTestCase(unittest.TestCase):
+
+    def test_read_multiline(self):
+        buf = StringIO(r'''msgid ""
+"Here's some text that\n"
+"includesareallylongwordthatmightbutshouldnt"
+" throw us into an infinite "
+"loop\n"
+msgstr ""''')
+        catalog = pofile.read_po(buf)
+        self.assertEqual(1, len(catalog))
+        message = list(catalog)[1]
+        self.assertEqual("Here's some text that\nincludesareallylongwordthat"
+                         "mightbutshouldnt throw us into an infinite loop\n",
+                         message.id)
+
+
 class WritePoTestCase(unittest.TestCase):
 
     def test_join_locations(self):
@@ -110,6 +127,7 @@
 def suite():
     suite = unittest.TestSuite()
     suite.addTest(doctest.DocTestSuite(pofile))
+    suite.addTest(unittest.makeSuite(ReadPoTestCase))
     suite.addTest(unittest.makeSuite(WritePoTestCase))
     return suite
 
Copyright (C) 2012-2017 Edgewall Software