summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-03-16 14:45:48 -0700
committerClaude Paroz <claude@2xlibre.net>2013-03-16 14:45:48 -0700
commit74a80a5169a1c870e6c2f78a18f67b366b0f60de (patch)
treebec1d7f759bf90d49b35a975915285c14d861b51
parentd7c83f25c7d0f78f0232ce23bf3f8783bc5c5294 (diff)
parentd5683bd06bdac923f73954020c760a4adb496be8 (diff)
Merge pull request #910 from bmispelon/ticket-20058
Fix #20058: Make compilemessages use stdout instead of stderr.
-rw-r--r--django/core/management/commands/compilemessages.py6
-rw-r--r--tests/i18n/commands/compilation.py12
2 files changed, 9 insertions, 9 deletions
diff --git a/django/core/management/commands/compilemessages.py b/django/core/management/commands/compilemessages.py
index 845ad159a9..cb41492004 100644
--- a/django/core/management/commands/compilemessages.py
+++ b/django/core/management/commands/compilemessages.py
@@ -15,7 +15,7 @@ def has_bom(fn):
sample.startswith(codecs.BOM_UTF16_LE) or \
sample.startswith(codecs.BOM_UTF16_BE)
-def compile_messages(stderr, locale=None):
+def compile_messages(stdout, locale=None):
program = 'msgfmt'
if find_command(program) is None:
raise CommandError("Can't find %s. Make sure you have GNU gettext tools 0.15 or newer installed." % program)
@@ -41,7 +41,7 @@ def compile_messages(stderr, locale=None):
for f in filenames:
if not f.endswith('.po'):
continue
- stderr.write('processing file %s in %s\n' % (f, dirpath))
+ stdout.write('processing file %s in %s\n' % (f, dirpath))
fn = os.path.join(dirpath, f)
if has_bom(fn):
raise CommandError("The %s file has a BOM (Byte Order Mark). Django only supports .po files encoded in UTF-8 and without any BOM." % fn)
@@ -68,4 +68,4 @@ class Command(BaseCommand):
def handle(self, **options):
locale = options.get('locale')
- compile_messages(self.stderr, locale=locale)
+ compile_messages(self.stdout, locale=locale)
diff --git a/tests/i18n/commands/compilation.py b/tests/i18n/commands/compilation.py
index aeeb3a4b0c..12bb89ed08 100644
--- a/tests/i18n/commands/compilation.py
+++ b/tests/i18n/commands/compilation.py
@@ -29,7 +29,7 @@ class PoFileTests(MessageCompilationTests):
def test_bom_rejection(self):
with self.assertRaises(CommandError) as cm:
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
self.assertIn("file has a BOM (Byte Order Mark)", cm.exception.args[0])
self.assertFalse(os.path.exists(self.MO_FILE))
@@ -45,7 +45,7 @@ class PoFileContentsTests(MessageCompilationTests):
self.addCleanup(os.unlink, os.path.join(test_dir, self.MO_FILE))
def test_percent_symbol_in_po_file(self):
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE))
@@ -63,7 +63,7 @@ class PercentRenderingTests(MessageCompilationTests):
@override_settings(LOCALE_PATHS=(os.path.join(test_dir, 'locale'),))
def test_percent_symbol_escaping(self):
from django.template import Template, Context
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())
with translation.override(self.LOCALE):
t = Template('{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}')
rendered = t.render(Context({}))
@@ -88,12 +88,12 @@ class MultipleLocaleCompilationTests(MessageCompilationTests):
self.addCleanup(self.rmfile, os.path.join(localedir, self.MO_FILE_FR))
def test_one_locale(self):
- call_command('compilemessages', locale='hr', stderr=StringIO())
+ call_command('compilemessages', locale='hr', stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE_HR))
def test_multiple_locales(self):
- call_command('compilemessages', locale=['hr', 'fr'], stderr=StringIO())
+ call_command('compilemessages', locale=['hr', 'fr'], stdout=StringIO())
self.assertTrue(os.path.exists(self.MO_FILE_HR))
self.assertTrue(os.path.exists(self.MO_FILE_FR))
@@ -110,4 +110,4 @@ class CompilationErrorHandling(MessageCompilationTests):
def test_error_reported_by_msgfmt(self):
with self.assertRaises(CommandError):
- call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
+ call_command('compilemessages', locale=self.LOCALE, stdout=StringIO())