comparison babel/messages/tests/pofile.py @ 190:5041d90edf0c trunk

Correctly write out obsolete messages spanning multiple lines. Fixes #33.
author cmlenz
date Sun, 01 Jul 2007 17:45:27 +0000
parents 8a762ce37bf7
children c171a0041ad2
comparison
equal deleted inserted replaced
189:cdb266cd9a19 190:5041d90edf0c
148 # multiple lines. 148 # multiple lines.
149 #: utils.py:3 149 #: utils.py:3
150 msgid "bar" 150 msgid "bar"
151 msgstr ""''', buf.getvalue().strip()) 151 msgstr ""''', buf.getvalue().strip())
152 152
153 def test_po_with_obsolete_messages(self): 153 def test_po_with_obsolete_message(self):
154 catalog = Catalog() 154 catalog = Catalog()
155 catalog.add(u'foo', u'Voh', locations=[('main.py', 1)]) 155 catalog.add(u'foo', u'Voh', locations=[('main.py', 1)])
156 catalog.obsolete['bar'] = Message(u'bar', u'Bahr', 156 catalog.obsolete['bar'] = Message(u'bar', u'Bahr',
157 locations=[('utils.py', 3)], 157 locations=[('utils.py', 3)],
158 user_comments=['User comment']) 158 user_comments=['User comment'])
163 msgstr "Voh" 163 msgstr "Voh"
164 164
165 # User comment 165 # User comment
166 #~ msgid "bar" 166 #~ msgid "bar"
167 #~ msgstr "Bahr"''', buf.getvalue().strip()) 167 #~ msgstr "Bahr"''', buf.getvalue().strip())
168
169 def test_po_with_multiline_obsolete_message(self):
170 catalog = Catalog()
171 catalog.add(u'foo', u'Voh', locations=[('main.py', 1)])
172 msgid = r"""Here's a message that covers
173 multiple lines, and should still be handled
174 correctly.
175 """
176 msgstr = r"""Here's a message that covers
177 multiple lines, and should still be handled
178 correctly.
179 """
180 catalog.obsolete[msgid] = Message(msgid, msgstr,
181 locations=[('utils.py', 3)])
182 buf = StringIO()
183 pofile.write_po(buf, catalog, omit_header=True)
184 self.assertEqual(r'''#: main.py:1
185 msgid "foo"
186 msgstr "Voh"
187
188 #~ msgid ""
189 #~ "Here's a message that covers\n"
190 #~ "multiple lines, and should still be handled\n"
191 #~ "correctly.\n"
192 #~ msgstr ""
193 #~ "Here's a message that covers\n"
194 #~ "multiple lines, and should still be handled\n"
195 #~ "correctly.\n"''', buf.getvalue().strip())
168 196
169 197
170 def suite(): 198 def suite():
171 suite = unittest.TestSuite() 199 suite = unittest.TestSuite()
172 suite.addTest(doctest.DocTestSuite(pofile)) 200 suite.addTest(doctest.DocTestSuite(pofile))
Copyright (C) 2012-2017 Edgewall Software