diff options
| author | Bartosz Grabski <bartosz.grabski@gmail.com> | 2018-05-27 14:09:54 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2018-06-12 08:29:22 -0400 |
| commit | c7d59825d738650e87173d4f9c8781b2e8b8c0c5 (patch) | |
| tree | afbfaf69c3616e3ce793ef4655521a6bd3b5c5d9 /tests/i18n/test_extraction.py | |
| parent | 91a02dce97ec677933527deddcce230e6e7ba7c9 (diff) | |
[2.1.x] Fixed #29452 -- Fixed makemessages setting charset of .pot files.
Backport of 2bc014750adb093131f77e4c20bc17ba64b75cac from master
Diffstat (limited to 'tests/i18n/test_extraction.py')
| -rw-r--r-- | tests/i18n/test_extraction.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py index d9ce3b43c7..e1463f2a8e 100644 --- a/tests/i18n/test_extraction.py +++ b/tests/i18n/test_extraction.py @@ -1,6 +1,7 @@ import os import re import shutil +import tempfile import time import warnings from io import StringIO @@ -12,7 +13,7 @@ from django.core import management from django.core.management import execute_from_command_line from django.core.management.base import CommandError from django.core.management.commands.makemessages import ( - Command as MakeMessagesCommand, + Command as MakeMessagesCommand, write_pot_file, ) from django.core.management.utils import find_command from django.test import SimpleTestCase, override_settings @@ -394,6 +395,26 @@ class BasicExtractorTests(ExtractorTests): po_contents = fp.read() self.assertMsgStr("Größe", po_contents) + def test_pot_charset_header_is_utf8(self): + """Content-Type: ... charset=CHARSET is replaced with charset=UTF-8""" + msgs = ( + '# SOME DESCRIPTIVE TITLE.\n' + '# (some lines truncated as they are not relevant)\n' + '"Content-Type: text/plain; charset=CHARSET\\n"\n' + '"Content-Transfer-Encoding: 8bit\\n"\n' + '\n' + '#: somefile.py:8\n' + 'msgid "mañana; charset=CHARSET"\n' + 'msgstr ""\n' + ) + with tempfile.NamedTemporaryFile() as pot_file: + pot_filename = pot_file.name + write_pot_file(pot_filename, msgs) + with open(pot_filename, 'r', encoding='utf-8') as fp: + pot_contents = fp.read() + self.assertIn('Content-Type: text/plain; charset=UTF-8', pot_contents) + self.assertIn('mañana; charset=CHARSET', pot_contents) + class JavascriptExtractorTests(ExtractorTests): |
