def setUp(self): self.base = StringsNode([EntryNode("spam", "spam"), EntryNode("egg", "egg"), EntryNode("ham", "ham")]) self.localized_before = StringsNode([EntryNode("spam", "spamspam"), EntryNode("ham", "hamham")]) self.localized_after = StringsNode( [EntryNode("spam", "spamspam"), EntryNode("ham", "hamham"), EntryNode("egg", "egg")] ) self.merger = StringsMerger(self.base)
class TestStringsMerger(unittest.TestCase): def setUp(self): self.base = StringsNode([EntryNode("spam", "spam"), EntryNode("egg", "egg"), EntryNode("ham", "ham")]) self.localized_before = StringsNode([EntryNode("spam", "spamspam"), EntryNode("ham", "hamham")]) self.localized_after = StringsNode( [EntryNode("spam", "spamspam"), EntryNode("ham", "hamham"), EntryNode("egg", "egg")] ) self.merger = StringsMerger(self.base) def testUpdate(self): merged = self.merger.update(self.localized_before) self.assertEqual(merged, self.localized_after)
def update(base, localizable): base_ast = make_ast(base) merger = StringsMerger(make_ast(base)) updated = merger.update(make_ast(localizable)) writer = StringsWriter(file=sys.stdout, encoding='utf-8') writer.write(updated)