mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #25677 -- Prevented decoding errors in/after Popen calls
Thanks Gavin Wahl for the report and Tim Graham for the review.
This commit is contained in:
24
tests/i18n/commands/locale/ko/LC_MESSAGES/django.po
Normal file
24
tests/i18n/commands/locale/ko/LC_MESSAGES/django.po
Normal file
@@ -0,0 +1,24 @@
|
||||
# This file intentionally contains a wrong msgstr that will produce
|
||||
# a msgfmt error.
|
||||
# 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: 2015-11-04 12:01-0700\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"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: \n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
|
||||
#: foo/password_validation.py:17
|
||||
#, python-brace-format
|
||||
msgid "Your password must contain a symbol: {symbols}"
|
||||
msgstr "[Ẏǿŭř ƥȧşşẇǿřḓ ḿŭşŧ ƈǿƞŧȧīƞ ȧ şẏḿƀǿŀ: {şẏḿƀǿŀş} ΐΰϖΐ ϖΐẛϕϐ]"
|
||||
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import gettext as gettext_module
|
||||
import os
|
||||
@@ -12,7 +13,7 @@ from django.core.management import (
|
||||
from django.core.management.utils import find_command
|
||||
from django.test import SimpleTestCase, override_settings
|
||||
from django.test.utils import captured_stderr, captured_stdout
|
||||
from django.utils import translation
|
||||
from django.utils import six, translation
|
||||
from django.utils._os import upath
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.six import StringIO
|
||||
@@ -154,17 +155,26 @@ class ExcludedLocaleCompilationTests(MessageCompilationTests):
|
||||
|
||||
|
||||
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(self.test_dir, self.MO_FILE))
|
||||
|
||||
def test_error_reported_by_msgfmt(self):
|
||||
# po file contains wrong po formatting.
|
||||
mo_file = 'locale/ja/LC_MESSAGES/django.mo'
|
||||
self.addCleanup(self.rmfile, os.path.join(self.test_dir, mo_file))
|
||||
with self.assertRaises(CommandError):
|
||||
call_command('compilemessages', locale=[self.LOCALE], stdout=StringIO())
|
||||
call_command('compilemessages', locale=['ja'], verbosity=0)
|
||||
|
||||
def test_msgfmt_error_including_non_ascii(self):
|
||||
# po file contains invalid msgstr content (triggers non-ascii error content).
|
||||
mo_file = 'locale/ko/LC_MESSAGES/django.mo'
|
||||
self.addCleanup(self.rmfile, os.path.join(self.test_dir, mo_file))
|
||||
if six.PY2:
|
||||
# Various assertRaises on PY2 don't support unicode error messages.
|
||||
try:
|
||||
call_command('compilemessages', locale=['ko'], verbosity=0)
|
||||
except CommandError as err:
|
||||
self.assertIn("'<EFBFBD>' cannot start a field name", six.text_type(err))
|
||||
else:
|
||||
with self.assertRaisesMessage(CommandError, "'<EFBFBD>' cannot start a field name"):
|
||||
call_command('compilemessages', locale=['ko'], verbosity=0)
|
||||
|
||||
|
||||
class ProjectAndAppTests(MessageCompilationTests):
|
||||
|
||||
Reference in New Issue
Block a user