From 72ee68d9a71561a4716378a002db344f4f2c3229 Mon Sep 17 00:00:00 2001 From: Alex Morega Date: Fri, 5 Jul 2013 15:35:37 +0200 Subject: [PATCH] extract expected and actual content for comparison --- babel/messages/tests/frontend.py | 111 ++++++++++++++++--------------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/babel/messages/tests/frontend.py b/babel/messages/tests/frontend.py index 2d934e7e..ef45c5ba 100644 --- a/babel/messages/tests/frontend.py +++ b/babel/messages/tests/frontend.py @@ -138,8 +138,7 @@ class ExtractMessagesTestCase(unittest.TestCase): self.assert_pot_file_exists() - self.assertEqual( -r"""# Translations template for TestProject. + expected_content = r"""# Translations template for TestProject. # Copyright (C) %(year)s FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -180,8 +179,9 @@ msgstr[1] "" """ % {'version': VERSION, 'year': time.strftime('%Y'), 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(self._pot_file(), 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(self._pot_file(), 'U').read() + self.assertEqual(expected_content, actual_content) def test_extraction_with_mapping_file(self): self.cmd.copyright_holder = 'FooBar, Inc.' @@ -195,8 +195,7 @@ msgstr[1] "" self.assert_pot_file_exists() - self.assertEqual( -r"""# Translations template for TestProject. + expected_content = r"""# Translations template for TestProject. # Copyright (C) %(year)s FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -231,8 +230,9 @@ msgstr[1] "" """ % {'version': VERSION, 'year': time.strftime('%Y'), 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(self._pot_file(), 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(self._pot_file(), 'U').read() + self.assertEqual(expected_content, actual_content) def test_extraction_with_mapping_dict(self): self.dist.message_extractors = { @@ -251,8 +251,7 @@ msgstr[1] "" self.assert_pot_file_exists() - self.assertEqual( -r"""# Translations template for TestProject. + expected_content = r"""# Translations template for TestProject. # Copyright (C) %(year)s FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -287,8 +286,9 @@ msgstr[1] "" """ % {'version': VERSION, 'year': time.strftime('%Y'), 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(self._pot_file(), 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(self._pot_file(), 'U').read() + self.assertEqual(expected_content, actual_content) class InitCatalogTestCase(unittest.TestCase): @@ -343,8 +343,7 @@ class InitCatalogTestCase(unittest.TestCase): po_file = self._po_file('en_US') assert os.path.isfile(po_file) - self.assertEqual( -r"""# English (United States) translations for TestProject. + expected_content = r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -378,8 +377,9 @@ msgstr[1] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_keeps_catalog_non_fuzzy(self): self.cmd.input_file = 'project/i18n/messages_non_fuzzy.pot' @@ -392,8 +392,7 @@ msgstr[1] "" po_file = self._po_file('en_US') assert os.path.isfile(po_file) - self.assertEqual( -r"""# English (United States) translations for TestProject. + expected_content = r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -427,8 +426,9 @@ msgstr[1] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_correct_init_more_than_2_plurals(self): self.cmd.input_file = 'project/i18n/messages.pot' @@ -441,8 +441,7 @@ msgstr[1] "" po_file = self._po_file('lv_LV') assert os.path.isfile(po_file) - self.assertEqual( -r"""# Latvian (Latvia) translations for TestProject. + expected_content = r"""# Latvian (Latvia) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -478,8 +477,9 @@ msgstr[2] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_correct_init_singular_plural_forms(self): self.cmd.input_file = 'project/i18n/messages.pot' @@ -492,8 +492,7 @@ msgstr[2] "" po_file = self._po_file('ja_JP') assert os.path.isfile(po_file) - self.assertEqual( -r"""# Japanese (Japan) translations for TestProject. + expected_content = r"""# Japanese (Japan) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -526,8 +525,9 @@ msgstr[0] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='ja_JP')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='ja_JP')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_supports_no_wrap(self): self.cmd.input_file = 'project/i18n/long_messages.pot' @@ -546,7 +546,7 @@ msgstr[0] "" po_file = self._po_file('en_US') assert os.path.isfile(po_file) - self.assertEqual(r"""# English (United States) translations for TestProject. + expected_content = r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -581,8 +581,9 @@ msgstr[1] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US'), - 'long_message': long_message}, - open(po_file, 'U').read()) + 'long_message': long_message} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_supports_width(self): self.cmd.input_file = 'project/i18n/long_messages.pot' @@ -600,8 +601,7 @@ msgstr[1] "" po_file = self._po_file('en_US') assert os.path.isfile(po_file) - self.assertEqual( -r"""# English (United States) translations for TestProject. + expected_content = r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -636,8 +636,9 @@ msgstr[1] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', tzinfo=LOCALTZ, locale='en_US'), - 'long_message': long_message}, - open(po_file, 'U').read()) + 'long_message': long_message} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) class CommandLineInterfaceTestCase(unittest.TestCase): @@ -753,8 +754,7 @@ commands: '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:', '-o', pot_file, 'project']) self.assert_pot_file_exists() - self.assertEqual( -r"""# Translations template for TestProject. + expected_content = r"""# Translations template for TestProject. # Copyright (C) %(year)s FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -795,8 +795,9 @@ msgstr[1] "" """ % {'version': VERSION, 'year': time.strftime('%Y'), 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(pot_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(pot_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_extract_with_mapping_file(self): pot_file = self._pot_file() @@ -808,8 +809,7 @@ msgstr[1] "" '-c', 'TRANSLATOR', '-c', 'TRANSLATORS:', '-o', pot_file, 'project']) self.assert_pot_file_exists() - self.assertEqual( -r"""# Translations template for TestProject. + expected_content = r"""# Translations template for TestProject. # Copyright (C) %(year)s FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -844,8 +844,9 @@ msgstr[1] "" """ % {'version': VERSION, 'year': time.strftime('%Y'), 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(pot_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(pot_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_init_with_output_dir(self): po_file = self._po_file('en_US') @@ -854,8 +855,7 @@ msgstr[1] "" '-d', os.path.join(self._i18n_dir()), '-i', os.path.join(self._i18n_dir(), 'messages.pot')]) assert os.path.isfile(po_file) - self.assertEqual( -r"""# English (United States) translations for TestProject. + expected_content = r"""# English (United States) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -890,8 +890,9 @@ msgstr[1] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def _i18n_dir(self): return os.path.join(self.datadir, 'project', 'i18n') @@ -903,8 +904,7 @@ msgstr[1] "" '-d', os.path.join(self._i18n_dir()), '-i', os.path.join(self._i18n_dir(), 'messages.pot')]) assert os.path.isfile(po_file) - self.assertEqual( -r"""# Japanese (Japan) translations for TestProject. + expected_content = r"""# Japanese (Japan) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -938,8 +938,9 @@ msgstr[0] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_init_more_than_2_plural_forms(self): po_file = self._po_file('lv_LV') @@ -948,8 +949,7 @@ msgstr[0] "" '-d', self._i18n_dir(), '-i', os.path.join(self._i18n_dir(), 'messages.pot')]) assert os.path.isfile(po_file) - self.assertEqual( -r"""# Latvian (Latvia) translations for TestProject. + expected_content = r"""# Latvian (Latvia) translations for TestProject. # Copyright (C) 2007 FooBar, Inc. # This file is distributed under the same license as the TestProject # project. @@ -986,8 +986,9 @@ msgstr[2] "" """ % {'version': VERSION, 'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ', - tzinfo=LOCALTZ, locale='en')}, - open(po_file, 'U').read()) + tzinfo=LOCALTZ, locale='en')} + actual_content = open(po_file, 'U').read() + self.assertEqual(expected_content, actual_content) def test_compile_catalog(self): po_file = self._po_file('de_DE') -- 2.47.2