Mercurial > babel > mirror
diff babel/messages/tests/pofile.py @ 582:3fd7fb953633 trunk
fix handling of messages containing '\\n' (#171)
author | fschwarz |
---|---|
date | Fri, 03 Aug 2012 22:41:49 +0000 |
parents | e8155a73ac2e |
children | 5c9dba5dd311 |
line wrap: on
line diff
--- a/babel/messages/tests/pofile.py +++ b/babel/messages/tests/pofile.py @@ -526,11 +526,26 @@ self.assertEqual(catalog['missing line number'].locations, []) self.assertEqual(catalog['broken line number'].locations, []) + +class PofileFunctionsTestCase(unittest.TestCase): + + def test_unescape(self): + escaped = u'"Say:\\n \\"hello, world!\\"\\n"' + unescaped = u'Say:\n "hello, world!"\n' + self.assertNotEqual(unescaped, escaped) + self.assertEqual(unescaped, pofile.unescape(escaped)) + + def test_unescape_of_quoted_newline(self): + # regression test for #198 + self.assertEqual(r'\n', pofile.unescape(r'"\\n"')) + + def suite(): suite = unittest.TestSuite() suite.addTest(doctest.DocTestSuite(pofile, optionflags=doctest.ELLIPSIS)) suite.addTest(unittest.makeSuite(ReadPoTestCase)) suite.addTest(unittest.makeSuite(WritePoTestCase)) + suite.addTest(unittest.makeSuite(PofileFunctionsTestCase)) return suite if __name__ == '__main__':