self.cmd.finalize_options()
self.cmd.run()
- catalog = read_po(open(self._pot_file(), 'U'))
+ with open(self._pot_file(), 'U') as f:
+ catalog = read_po(f)
msg = catalog.get('bar')
self.assertEqual(1, len(msg.locations))
self.assertTrue('file1.py' in msg.locations[0][0])
'year': time.strftime('%Y'),
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(self._pot_file(), 'U').read()
+ with open(self._pot_file(), 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_extraction_with_mapping_file(self):
'year': time.strftime('%Y'),
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(self._pot_file(), 'U').read()
+ with open(self._pot_file(), 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_extraction_with_mapping_dict(self):
'year': time.strftime('%Y'),
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(self._pot_file(), 'U').read()
+ with open(self._pot_file(), 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_keeps_catalog_non_fuzzy(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_correct_init_more_than_2_plurals(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_correct_init_singular_plural_forms(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='ja_JP')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_supports_no_wrap(self):
long_message = '"'+ 'xxxxx '*15 + '"'
- pot_contents = open('project/i18n/messages.pot', 'U').read()
+ with open('project/i18n/messages.pot', 'U') as f:
+ pot_contents = f.read()
pot_with_very_long_line = pot_contents.replace('"bar"', long_message)
- open(self.cmd.input_file, 'wb').write(pot_with_very_long_line)
+ with open(self.cmd.input_file, 'wb') as f:
+ f.write(pot_with_very_long_line)
self.cmd.no_wrap = True
self.cmd.finalize_options()
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en_US'),
'long_message': long_message}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_supports_width(self):
long_message = '"'+ 'xxxxx '*15 + '"'
- pot_contents = open('project/i18n/messages.pot', 'U').read()
+ with open('project/i18n/messages.pot', 'U') as f:
+ pot_contents = f.read()
pot_with_very_long_line = pot_contents.replace('"bar"', long_message)
- open(self.cmd.input_file, 'wb').write(pot_with_very_long_line)
+ with open(self.cmd.input_file, 'wb') as f:
+ f.write(pot_with_very_long_line)
self.cmd.width = 120
self.cmd.finalize_options()
self.cmd.run()
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en_US'),
'long_message': long_message}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
'year': time.strftime('%Y'),
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(pot_file, 'U').read()
+ with open(pot_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_extract_with_mapping_file(self):
'year': time.strftime('%Y'),
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(pot_file, 'U').read()
+ with open(pot_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_init_with_output_dir(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def _i18n_dir(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_init_more_than_2_plural_forms(self):
""" % {'version': VERSION,
'date': format_datetime(datetime.now(LOCALTZ), 'yyyy-MM-dd HH:mmZ',
tzinfo=LOCALTZ, locale='en')}
- actual_content = open(po_file, 'U').read()
+ with open(po_file, 'U') as f:
+ actual_content = f.read()
self.assertEqual(expected_content, actual_content)
def test_compile_catalog(self):