summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2014-01-04 22:26:24 +0100
committerClaude Paroz <claude@2xlibre.net>2014-02-18 13:38:06 +0100
commit621c5cf4a501c8e80348df0ddbe726defd6be2ed (patch)
treeb906fb90d9e3976743cc53e7b9a8889216f89272 /tests
parent203f55b5d5e2476a9bef7fe50796103f76f378e8 (diff)
Fixed #21732 -- Made compilemessages complain about non-writable location
Instead of crashing with a CommandError, now a non-writable location of mo files will only make compilemessages complain and continue. Thanks Ramiro Morales for the review.
Diffstat (limited to 'tests')
-rw-r--r--tests/i18n/commands/locale/en/LC_MESSAGES/django.mobin0 -> 378 bytes
-rw-r--r--tests/i18n/commands/locale/en/LC_MESSAGES/django.po27
-rw-r--r--tests/i18n/test_compilation.py14
3 files changed, 41 insertions, 0 deletions
diff --git a/tests/i18n/commands/locale/en/LC_MESSAGES/django.mo b/tests/i18n/commands/locale/en/LC_MESSAGES/django.mo
new file mode 100644
index 0000000000..b79b39100b
--- /dev/null
+++ b/tests/i18n/commands/locale/en/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/commands/locale/en/LC_MESSAGES/django.po b/tests/i18n/commands/locale/en/LC_MESSAGES/django.po
new file mode 100644
index 0000000000..ddb831b24b
--- /dev/null
+++ b/tests/i18n/commands/locale/en/LC_MESSAGES/django.po
@@ -0,0 +1,27 @@
+# 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.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2014-01-04 22:05+0100\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#. Translators: This comment should be extracted
+#: __init__.py:4
+msgid "This is a translatable string."
+msgstr ""
+
+#: __init__.py:7
+msgid "This is another translatable string."
+msgstr ""
diff --git a/tests/i18n/test_compilation.py b/tests/i18n/test_compilation.py
index ae92f6f368..463ff21d23 100644
--- a/tests/i18n/test_compilation.py
+++ b/tests/i18n/test_compilation.py
@@ -1,4 +1,5 @@
import os
+import stat
import unittest
from django.core.management import call_command, CommandError
@@ -37,6 +38,19 @@ class PoFileTests(MessageCompilationTests):
self.assertIn("file has a BOM (Byte Order Mark)", cm.exception.args[0])
self.assertFalse(os.path.exists(self.MO_FILE))
+ def test_no_write_access(self):
+ mo_file_en = 'locale/en/LC_MESSAGES/django.mo'
+ err_buffer = StringIO()
+ # put file in read-only mode
+ old_mode = os.stat(mo_file_en).st_mode
+ os.chmod(mo_file_en, stat.S_IREAD)
+ try:
+ call_command('compilemessages', locale=['en'], stderr=err_buffer, verbosity=0)
+ err = err_buffer.getvalue()
+ self.assertIn("not writable location", err)
+ finally:
+ os.chmod(mo_file_en, old_mode)
+
class PoFileContentsTests(MessageCompilationTests):
# Ticket #11240