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.
""" % {'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.'
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.
""" % {'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 = {
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.
""" % {'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):
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.
""" % {'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'
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.
""" % {'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'
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.
""" % {'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'
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.
""" % {'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'
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.
""" % {'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'
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.
""" % {'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):
'-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.
""" % {'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()
'-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.
""" % {'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')
'-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.
""" % {'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')
'-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.
""" % {'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')
'-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.
""" % {'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')