def test_insert1(self): pofile = polib.pofile('tests/test_pofile_helpers.po') entry = polib.POEntry(msgid="Foo", msgstr="Bar", msgctxt="Some context") pofile.insert(0, entry) self.assertEqual(pofile[0], entry)
def test_append1(self): pofile = polib.pofile('tests/test_pofile_helpers.po') entry = polib.POEntry(msgid="Foo", msgstr="Bar", msgctxt="Some context") pofile.append(entry) self.assertTrue(entry in pofile)
def test_sort(self): a1 = polib.POEntry(msgid='a1', occurrences=[('b.py', 1), ('b.py', 3)]) a2 = polib.POEntry(msgid='a2') a3 = polib.POEntry(msgid='a1', occurrences=[('b.py', 1), ('b.py', 3)], obsolete=True) b1 = polib.POEntry(msgid='b1', occurrences=[('b.py', 1), ('b.py', 3)]) b2 = polib.POEntry(msgid='b2', occurrences=[('d.py', 3), ('b.py', 1)]) c1 = polib.POEntry(msgid='c1', occurrences=[('a.py', 1), ('b.py', 1)]) c2 = polib.POEntry(msgid='c2', occurrences=[('a.py', 1), ('a.py', 3)]) pofile = polib.POFile() pofile.append(b1) pofile.append(a3) pofile.append(a2) pofile.append(a1) pofile.append(b2) pofile.append(c1) pofile.append(c2) pofile.sort() expected = '''# msgid "" msgstr "" msgid "a2" msgstr "" #: a.py:1 a.py:3 msgid "c2" msgstr "" #: a.py:1 b.py:1 msgid "c1" msgstr "" #: b.py:1 b.py:3 msgid "a1" msgstr "" #: b.py:1 b.py:3 msgid "b1" msgstr "" #: d.py:3 b.py:1 msgid "b2" msgstr "" #~ msgid "a1" #~ msgstr "" ''' self.assertEqual(pofile.__unicode__(), expected)
def test_compare4(self): entry1 = polib.POEntry(msgid='test1') entry2 = polib.POEntry(msgid_plural='test0') self.assertTrue(entry2 > entry1)
def test_compare2(self): entry1 = polib.POEntry(msgid='test1') entry2 = polib.POEntry(msgid='test1', msgctxt='testc') self.assertTrue(entry2 > entry1)
def test_compare1(self): entry1 = polib.POEntry(msgid='test1') entry2 = polib.POEntry(msgid='test1') self.assertEqual(entry1, entry2)
def add_duplicate(): pofile = polib.pofile('tests/test_pofile_helpers.po', check_for_duplicates=True) pofile.insert(0, polib.POEntry(msgid="and", msgstr="y"))
def test_append4(self): pofile = polib.pofile('tests/test_pofile_helpers.po', check_for_duplicates=True) entry = polib.POEntry(msgid="and", msgctxt="some different context") pofile.append(entry) self.assertTrue(entry in pofile)
def add_duplicate(): pofile = polib.pofile('tests/test_pofile_helpers.po', check_for_duplicates=True) pofile.append(polib.POEntry(msgid="and", msgctxt="some context"))