1
0
mirror of https://github.com/django/django.git synced 2025-10-25 22:56:12 +00:00

Fixed #20311 -- Make sure makemessages doesn't create duplicate Plural-Forms .po file headers.

Thanks naktinis for the report and initial patch.
This commit is contained in:
Ramiro Morales
2013-06-22 18:39:14 -03:00
parent ecf63d5d89
commit 1559f84d8b
4 changed files with 33 additions and 4 deletions

View File

@@ -329,6 +329,15 @@ class SymlinkExtractorTests(ExtractorTests):
class CopyPluralFormsExtractorTests(ExtractorTests):
PO_FILE_ES = 'locale/es/LC_MESSAGES/django.po'
def tearDown(self):
os.chdir(self.test_dir)
try:
self._rmrf('locale/es')
except OSError:
pass
os.chdir(self._cwd)
def test_copy_plural_forms(self):
os.chdir(self.test_dir)
@@ -338,6 +347,16 @@ class CopyPluralFormsExtractorTests(ExtractorTests):
po_contents = force_text(fp.read())
self.assertTrue('Plural-Forms: nplurals=2; plural=(n != 1)' in po_contents)
def test_override_plural_forms(self):
"""Ticket #20311."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale='es', extensions=['djtpl'], verbosity=0)
self.assertTrue(os.path.exists(self.PO_FILE_ES))
with open(self.PO_FILE_ES, 'r') as fp:
po_contents = force_text(fp.read())
found = re.findall(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', po_contents, re.MULTILINE | re.DOTALL)
self.assertEqual(1, len(found))
class NoWrapExtractorTests(ExtractorTests):