Skip to content

Commit 24d89a6

Browse files
committed
Cosmetic improvements after review.
1 parent 46c08c5 commit 24d89a6

File tree

2 files changed

+66
-58
lines changed

2 files changed

+66
-58
lines changed

Lib/test/test_tools/test_msgfmt.py

Lines changed: 65 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from test.support.script_helper import assert_python_failure, assert_python_ok
1010
from test.test_tools import skip_if_missing, toolsdir
1111

12-
1312
skip_if_missing('i18n')
1413

1514
data_dir = (Path(__file__).parent / 'msgfmt_data').resolve()
@@ -91,6 +90,7 @@ def test_generic_syntax_error(self):
9190
err = res.err.decode('utf-8')
9291
self.assertIn('Syntax error', err)
9392

93+
9494
class CLITest(unittest.TestCase):
9595

9696
def test_help(self):
@@ -122,13 +122,14 @@ def test_nonexistent_file(self):
122122

123123

124124
class Test_multi_input(unittest.TestCase):
125-
"""Tests for the msgfmt.py tool
126-
bpo-35335 - bpo-9741
125+
"""Tests for the issue https://github.com/python/cpython/issues/79516
126+
msgfmt.py shall accept multiple input files and when imported
127+
make shall be callable multiple times
127128
"""
128129

129130
script = os.path.join(toolsdir, 'i18n', 'msgfmt.py')
130131

131-
# binary images of tiny po files
132+
# binary contents of tiny po files
132133
# windows end of lines for first one
133134
file1_fr_po = b'''# French translations for python package.\r
134135
# Copyright (C) 2018 THE python\'S COPYRIGHT HOLDER\r
@@ -189,58 +190,65 @@ class Test_multi_input(unittest.TestCase):
189190
msgstr "Au revoir ..."
190191
'''
191192

192-
# binary images of corresponding compiled mo files
193-
file1_fr_mo = b'\xde\x12\x04\x95\x00\x00\x00\x00\x03\x00\x00\x00\x1c' \
194-
b'\x00\x00\x004\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' \
195-
b'\x00\x00\x00\x00\x00L\x00\x00\x00\x06\x00\x00\x00M' \
196-
b'\x00\x00\x00\x14\x00\x00\x00T\x00\x00\x00[\x01\x00' \
197-
b'\x00i\x00\x00\x00\t\x00\x00\x00\xc5\x01\x00\x00\x16' \
198-
b'\x00\x00\x00\xcf\x01\x00\x00\x00Hello!\x00{n} horse' \
199-
b'\x00{n} horses\x00Project-Id-Version: python 3.8\n' \
200-
b'Report-Msgid-Bugs-To: \nPOT-Creation-Date: 2018-11-30 ' \
201-
b'23:46+0100\nPO-Revision-Date: 2018-11-30 23:47+0100\n'\
202-
b'Last-Translator: s-ball <[email protected]>\n' \
203-
b'Language-Team: French\nLanguage: fr\nMIME-Version: 1.0' \
204-
b'\nContent-Type: text/plain; charset=UTF-8\nContent-' \
205-
b'Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2' \
206-
b'; plural=(n > 1);\n\x00Bonjour !\x00{n} cheval\x00{n' \
207-
b'} chevaux\x00'
208-
file2_fr_mo = b"\xde\x12\x04\x95\x00\x00\x00\x00\x03\x00\x00\x00" \
209-
b"\x1c\x00\x00\x004\x00\x00\x00\x00\x00\x00\x00\x00" \
210-
b"\x00\x00\x00\x00\x00\x00\x00L\x00\x00\x00\x06\x00" \
211-
b"\x00\x00M\x00\x00\x00\n\x00\x00\x00T\x00\x00\x00[" \
212-
b"\x01\x00\x00_\x00\x00\x00\r\x00\x00\x00\xbb\x01" \
213-
b"\x00\x00\x0f\x00\x00\x00\xc9\x01\x00\x00\x00Bye.." \
214-
b".\x00It's over.\x00Project-Id-Version: python 3.8" \
215-
b"\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2018" \
216-
b"-11-30 23:57+0100\nPO-Revision-Date: 2018-11-30 2" \
217-
b"3:57+0100\nLast-Translator: s-ball <s-ball@lapost" \
218-
b"e.net>\nLanguage-Team: French\nLanguage: fr\nMIME" \
219-
b"-Version: 1.0\nContent-Type: text/plain; charset=" \
220-
b"UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Fo" \
221-
b"rms: nplurals=2; plural=(n > 1);\n\x00Au revoir ." \
222-
b"..\x00C'est termin\xc3\xa9.\x00"
223-
224-
# image of merging both po files keeping second header
225-
file12_fr_mo = b"\xde\x12\x04\x95\x00\x00\x00\x00\x05\x00\x00\x00" \
226-
b"\x1c\x00\x00\x00D\x00\x00\x00\x00\x00\x00\x00\x00" \
227-
b"\x00\x00\x00\x00\x00\x00\x00l\x00\x00\x00\x06\x00" \
228-
b"\x00\x00m\x00\x00\x00\x06\x00\x00\x00t\x00\x00\x00" \
229-
b"\n\x00\x00\x00{\x00\x00\x00\x14\x00\x00\x00\x86" \
230-
b"\x00\x00\x00[\x01\x00\x00\x9b\x00\x00\x00\r\x00" \
231-
b"\x00\x00\xf7\x01\x00\x00\t\x00\x00\x00\x05\x02\x00" \
232-
b"\x00\x0f\x00\x00\x00\x0f\x02\x00\x00\x16\x00\x00" \
233-
b"\x00\x1f\x02\x00\x00\x00Bye...\x00Hello!\x00It's " \
234-
b"over.\x00{n} horse\x00{n} horses\x00Project-Id-Ver" \
235-
b"sion: python 3.8\nReport-Msgid-Bugs-To: \nPOT-Crea" \
236-
b"tion-Date: 2018-11-30 23:57+0100\nPO-Revision-Date" \
237-
b": 2018-11-30 23:57+0100\nLast-Translator: s-ball <" \
238-
b"[email protected]>\nLanguage-Team: French\nLangua" \
239-
b"ge: fr\nMIME-Version: 1.0\nContent-Type: text/plai" \
240-
b"n; charset=UTF-8\nContent-Transfer-Encoding: 8bit" \
241-
b"\nPlural-Forms: nplurals=2; plural=(n > 1);\n\x00A" \
242-
b"u revoir ...\x00Bonjour !\x00C'est termin\xc3\xa9." \
243-
b"\x00{n} cheval\x00{n} chevaux\x00"
193+
# binary contents of corresponding compiled mo files
194+
file1_fr_mo = (
195+
b'\xde\x12\x04\x95\x00\x00\x00\x00\x03\x00\x00\x00\x1c'
196+
b'\x00\x00\x004\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
197+
b'\x00\x00\x00\x00\x00L\x00\x00\x00\x06\x00\x00\x00M'
198+
b'\x00\x00\x00\x14\x00\x00\x00T\x00\x00\x00[\x01\x00'
199+
b'\x00i\x00\x00\x00\t\x00\x00\x00\xc5\x01\x00\x00\x16'
200+
b'\x00\x00\x00\xcf\x01\x00\x00\x00Hello!\x00{n} horse'
201+
b'\x00{n} horses\x00Project-Id-Version: python 3.8\n'
202+
b'Report-Msgid-Bugs-To: \nPOT-Creation-Date: 2018-11-30 '
203+
b'23:46+0100\nPO-Revision-Date: 2018-11-30 23:47+0100\n'
204+
b'Last-Translator: s-ball <[email protected]>\n'
205+
b'Language-Team: French\nLanguage: fr\nMIME-Version: 1.0'
206+
b'\nContent-Type: text/plain; charset=UTF-8\nContent-'
207+
b'Transfer-Encoding: 8bit\nPlural-Forms: nplurals=2'
208+
b'; plural=(n > 1);\n\x00Bonjour !\x00{n} cheval\x00{n'
209+
b'} chevaux\x00'
210+
)
211+
file2_fr_mo = (
212+
b"\xde\x12\x04\x95\x00\x00\x00\x00\x03\x00\x00\x00"
213+
b"\x1c\x00\x00\x004\x00\x00\x00\x00\x00\x00\x00\x00"
214+
b"\x00\x00\x00\x00\x00\x00\x00L\x00\x00\x00\x06\x00"
215+
b"\x00\x00M\x00\x00\x00\n\x00\x00\x00T\x00\x00\x00["
216+
b"\x01\x00\x00_\x00\x00\x00\r\x00\x00\x00\xbb\x01"
217+
b"\x00\x00\x0f\x00\x00\x00\xc9\x01\x00\x00\x00Bye.."
218+
b".\x00It's over.\x00Project-Id-Version: python 3.8"
219+
b"\nReport-Msgid-Bugs-To: \nPOT-Creation-Date: 2018"
220+
b"-11-30 23:57+0100\nPO-Revision-Date: 2018-11-30 2"
221+
b"3:57+0100\nLast-Translator: s-ball <s-ball@lapost"
222+
b"e.net>\nLanguage-Team: French\nLanguage: fr\nMIME"
223+
b"-Version: 1.0\nContent-Type: text/plain; charset="
224+
b"UTF-8\nContent-Transfer-Encoding: 8bit\nPlural-Fo"
225+
b"rms: nplurals=2; plural=(n > 1);\n\x00Au revoir ."
226+
b"..\x00C'est termin\xc3\xa9.\x00"
227+
)
228+
229+
# content of merging both po files keeping second header
230+
file12_fr_mo = (
231+
b"\xde\x12\x04\x95\x00\x00\x00\x00\x05\x00\x00\x00"
232+
b"\x1c\x00\x00\x00D\x00\x00\x00\x00\x00\x00\x00\x00"
233+
b"\x00\x00\x00\x00\x00\x00\x00l\x00\x00\x00\x06\x00"
234+
b"\x00\x00m\x00\x00\x00\x06\x00\x00\x00t\x00\x00\x00"
235+
b"\n\x00\x00\x00{\x00\x00\x00\x14\x00\x00\x00\x86"
236+
b"\x00\x00\x00[\x01\x00\x00\x9b\x00\x00\x00\r\x00"
237+
b"\x00\x00\xf7\x01\x00\x00\t\x00\x00\x00\x05\x02\x00"
238+
b"\x00\x0f\x00\x00\x00\x0f\x02\x00\x00\x16\x00\x00"
239+
b"\x00\x1f\x02\x00\x00\x00Bye...\x00Hello!\x00It's "
240+
b"over.\x00{n} horse\x00{n} horses\x00Project-Id-Ver"
241+
b"sion: python 3.8\nReport-Msgid-Bugs-To: \nPOT-Crea"
242+
b"tion-Date: 2018-11-30 23:57+0100\nPO-Revision-Date"
243+
b": 2018-11-30 23:57+0100\nLast-Translator: s-ball <"
244+
b"[email protected]>\nLanguage-Team: French\nLangua"
245+
b"ge: fr\nMIME-Version: 1.0\nContent-Type: text/plai"
246+
b"n; charset=UTF-8\nContent-Transfer-Encoding: 8bit"
247+
b"\nPlural-Forms: nplurals=2; plural=(n > 1);\n\x00A"
248+
b"u revoir ...\x00Bonjour !\x00C'est termin\xc3\xa9."
249+
b"\x00{n} cheval\x00{n} chevaux\x00"
250+
)
251+
244252
def imp(self):
245253
i18ndir = os.path.join(toolsdir, 'i18n')
246254
sys.path.append(i18ndir)
@@ -316,7 +324,7 @@ def test_both_without_outputfile(self):
316324

317325
def test_consecutive_make_calls(self):
318326
"""Directly calls make twice to prove bpo-9741 is fixed"""
319-
sys.path.append(os.path.join(toolsdir,'i18n'))
327+
sys.path.append(os.path.join(toolsdir, 'i18n'))
320328
from msgfmt import make
321329
with temp_cwd(None):
322330
with open("file1_fr.po", "wb") as out:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
It is now possible to merge more than one single po file into a compiled mo
1+
The script ``Tools/i18n/msgfmt.py`` is now able to merge more than one single po file into a compiled mo
22
file. When an entry exists in more than on input file, the last file wins.
33
It is also possible to directly call ``make`` more than once

0 commit comments

Comments
 (0)