def __init__( self, msgid, msgstr='', references=[], automatic_comments=[], comments=[]): """Build a MessageEntry. """ self.msgid = msgid self.msgstr = undouble_unicode_escape(msgstr) self.references = references self.automatic_comments = automatic_comments self.comments = comments
def test_roundtrip_string(self): self.assertEqual(undouble_unicode_escape('foo'), 'foo')
def test_encoded_escaped_kili(self): garbled = 'K\\u0131l\\u0131\xe7aslan' # actually: bytes goodname = u'Kılıçaslan' self.assertEqual(undouble_unicode_escape(garbled), goodname)
def test_encoded_escaped_seen_in_wild(self): garbled = 'msgstr "Polo\\u017eka ${title} byla odstran\\u011bna."' goodname = u'msgstr "Položka ${title} byla odstraněna."' self.assertEqual(undouble_unicode_escape(garbled), goodname)
def test_triple_encoded(self): garbled = 'K\xc3\x84\xc2\xb1l\xc3\x84\xc2\xb1\xc3\x83\xc2\xa7aslan' goodname = u'Kılıçaslan' self.assertEqual(undouble_unicode_escape(garbled), goodname)
def test_object(self): NO_VALUE = object() self.assertEqual(undouble_unicode_escape(NO_VALUE), NO_VALUE)
def test_roundtrip_complex_unicode(self): goodname = u'Kılıçaslan' self.assertEqual(undouble_unicode_escape(goodname), goodname)
def test_encoded(self): garbled = u'K\u0131l\u0131\xe7aslan' goodname = u'Kılıçaslan' self.assertEqual(undouble_unicode_escape(garbled), goodname)
def test_roundtrip_simple_unicode(self): self.assertEqual(undouble_unicode_escape(u'foo'), u'foo')