diff options
| author | Ramiro Morales <ramiro@rmorales.net> | 2013-10-21 00:22:32 -0300 |
|---|---|---|
| committer | Ramiro Morales <ramiro@rmorales.net> | 2013-10-22 07:38:02 -0300 |
| commit | b987fb188d3940830e323eed4ea6a121192011cd (patch) | |
| tree | a84541928f947f4caf7bc88b0db4ba95bf20793a /tests | |
| parent | 71306096542f5c1587cd6dd0de99e550608400cb (diff) | |
[1.6.x] Decode from UTF-8 explicitly when reading a text file in makemessages.
This shows itself with Python 3 under Windows where UTF-8 usually isn't
the default file I/O encoding and caused one failure and three errors
in our test suite under that platform setup.
b5f52647fe from master.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/commands/extraction.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/i18n/commands/extraction.py b/tests/i18n/commands/extraction.py index 79099a7fb0..18a9040126 100644 --- a/tests/i18n/commands/extraction.py +++ b/tests/i18n/commands/extraction.py @@ -1,6 +1,7 @@ # -*- encoding: utf-8 -*- from __future__ import unicode_literals +import io import os import re import shutil @@ -65,8 +66,8 @@ class BasicExtractorTests(ExtractorTests): os.chdir(self.test_dir) management.call_command('makemessages', locale=LOCALE, verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE)) - with open(self.PO_FILE, 'r') as fp: - po_contents = force_text(fp.read()) + with io.open(self.PO_FILE, 'r', encoding='utf-8') as fp: + po_contents = fp.read() self.assertTrue('#. Translators: This comment should be extracted' in po_contents) self.assertTrue('This comment should not be extracted' not in po_contents) # Comments in templates @@ -363,8 +364,8 @@ class CopyPluralFormsExtractorTests(ExtractorTests): os.chdir(self.test_dir) management.call_command('makemessages', locale='es', extensions=['djtpl'], verbosity=0) self.assertTrue(os.path.exists(self.PO_FILE_ES)) - with open(self.PO_FILE_ES, 'r') as fp: - po_contents = force_text(fp.read()) + with io.open(self.PO_FILE_ES, 'r', encoding='utf-8') as fp: + po_contents = fp.read() found = re.findall(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', po_contents, re.MULTILINE | re.DOTALL) self.assertEqual(1, len(found)) |
