class TestMergeStringsFile(unittest.TestCase, TestStringsTableContentMixin): def setUp(self): self.strings_table = StringsTable(os.path.join(source_root, 'example.strings'), encoding='utf-8') self.another_strings_table = StringsTable(os.path.join(source_root, 'example2.strings'), encoding='utf-8') def test_merge_default(self): self.strings_table.merge(self.another_strings_table) self.assertEqual(len(self.strings_table), 9) self._test_strings_table_content(self.strings_table, expected_results=self.default_expected_results + ( ExpectedResult("a key", "一個鑰匙", "A key"), )) def test_merge_not_keep_comment(self): self.strings_table.merge(self.another_strings_table, keep_comment=False) self._test_strings_table_content(self.strings_table, expected_results=( ExpectedResult("%@ doesn't have a list named %@.", "%1$@ は %2$@ というリストをもっていません。", "Some comemnt"), ExpectedResult("Cannot get the version of this Tickle document.", "Cannot get the version of this Tickle document.", 'Error message when Tickle tries to open a document but fails to fetch the version info,\n' ' English source is "Cannot get the version of this Tickle document."'), ExpectedResult("No comment", "沒有註解", None), ExpectedResult("String with \"quote\".\"", "有引號的字\"", "Comment with \"QUOTE\""), ExpectedResult("String with =", "String with =", "String with ="), ExpectedResult("String with ;", "String with ;", "String with semicolon"), ExpectedResult(r"String\twith \n", r"String\twith \n", "String with spaces"), ExpectedResult("String not translated", "String not translated", "Not translated"), ExpectedResult("a key", "一個鑰匙", "A key"), )) def test_merge_not_keep_localized(self): self.strings_table.merge(self.another_strings_table, keep_localized=False) self._test_strings_table_content(self.strings_table, expected_results=( ExpectedResult("%@ doesn't have a list named %@.", "%1$@ は %2$@ というリストをもっていません。", "Some comemnt"), ExpectedResult("Cannot get the version of this Tickle document.", "Cannot get the version of this Tickle document.", 'Error message when Tickle tries to open a document but fails to fetch the version info,\n' ' English source is "Cannot get the version of this Tickle document."'), ExpectedResult("No comment", "kein Kommentar", None), ExpectedResult("String with \"quote\".\"", "有引號的字\"", "Comment with \"quote\""), ExpectedResult("String with =", "String with =", "String with ="), ExpectedResult("String with ;", "String with ;", "String with semicolon"), ExpectedResult(r"String\twith \n", r"String\twith \n", "String with spaces"), ExpectedResult("String not translated", "String not translated", "Not translated"), ExpectedResult("a key", "一個鑰匙", "A key"), )) def test_merge_exclude_extra(self): self.strings_table.merge(self.another_strings_table, exclude_extra=True) self._test_strings_table_content(self.strings_table, expected_results=( ExpectedResult("%@ doesn't have a list named %@.", "%1$@ は %2$@ というリストをもっていません。", "Some comemnt"), ExpectedResult("Cannot get the version of this Tickle document.", "Cannot get the version of this Tickle document.", 'Error message when Tickle tries to open a document but fails to fetch the version info,\n' ' English source is "Cannot get the version of this Tickle document."'), ExpectedResult("No comment", "沒有註解", None), ExpectedResult("String with \"quote\".\"", "有引號的字\"", "Comment with \"quote\""), ExpectedResult("String with =", "String with =", "String with ="), ExpectedResult(r"String\twith \n", r"String\twith \n", "String with spaces"), ExpectedResult("a key", "一個鑰匙", "A key"), ))