summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRamiro Morales <cramm0@gmail.com>2013-02-12 13:58:49 -0300
committerRamiro Morales <cramm0@gmail.com>2013-02-26 21:31:53 -0300
commitdfa9324966ce1a38346d15e35805d042848aabf1 (patch)
treefbdc4f167056a84a1c6d38bf0a4ea7c5ab8cb145 /tests
parent5c51d71f9ae40f002530d9f4f2f477abaa76d78d (diff)
Don't use os.system() in compilemessages.
Fixes #19584. This implies stop storing file path command line arguments in envvars as a security measure to start relying on with Popen's shell=False instead, and addition of an 'utils' module. Thanks kmichel_wgs for the report.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/commands/compilation.py19
-rw-r--r--tests/i18n/commands/locale/ja/LC_MESSAGES/django.po21
-rw-r--r--tests/i18n/tests.py3
3 files changed, 42 insertions, 1 deletions
diff --git a/tests/i18n/commands/compilation.py b/tests/i18n/commands/compilation.py
index c15b95eb0e..705ed63de5 100644
--- a/tests/i18n/commands/compilation.py
+++ b/tests/i18n/commands/compilation.py
@@ -99,3 +99,22 @@ class MultipleLocaleCompilationTests(MessageCompilationTests):
self.assertTrue(os.path.exists(self.MO_FILE_HR))
self.assertTrue(os.path.exists(self.MO_FILE_FR))
+
+
+class CompilationErrorHandling(MessageCompilationTests):
+
+ LOCALE='ja'
+ MO_FILE='locale/%s/LC_MESSAGES/django.mo' % LOCALE
+
+ def setUp(self):
+ super(CompilationErrorHandling, self).setUp()
+ self.addCleanup(self._rmfile, os.path.join(test_dir, self.MO_FILE))
+
+ def _rmfile(self, filepath):
+ if os.path.exists(filepath):
+ os.remove(filepath)
+
+ def test_error_reported_by_msgfmt(self):
+ os.chdir(test_dir)
+ with self.assertRaises(CommandError):
+ call_command('compilemessages', locale=self.LOCALE, stderr=StringIO())
diff --git a/tests/i18n/commands/locale/ja/LC_MESSAGES/django.po b/tests/i18n/commands/locale/ja/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..08d6be1e63
--- /dev/null
+++ b/tests/i18n/commands/locale/ja/LC_MESSAGES/django.po
@@ -0,0 +1,21 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2011-12-04 04:59-0600\n"
+"PO-Revision-Date: 2013-02-26 21:29-0300\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: ja\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=1; plural=0;\n"
+
+#, brainfuck-format
+msgwhat!? "This is an invalid PO file. GNU msgfmt should reject it."
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index c9abe01f8c..4d06c85c97 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -41,7 +41,8 @@ if can_run_extraction_tests:
MultipleLocaleExtractionTests)
if can_run_compilation_tests:
from .commands.compilation import (PoFileTests, PoFileContentsTests,
- PercentRenderingTests, MultipleLocaleCompilationTests)
+ PercentRenderingTests, MultipleLocaleCompilationTests,
+ CompilationErrorHandling)
from .contenttypes.tests import ContentTypeTests
from .forms import I18nForm, SelectDateForm, SelectDateWidget, CompanyForm
from .models import Company, TestModel