Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.3k
[3.13] gh-130197: pygettext: Test the --escape option (GH-131902)#132032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
(cherry picked from commit87d9983)Co-authored-by: Tomas R. <tomas.roun8@gmail.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\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" | ||
"Generated-By: pygettext.py 1.5\n" | ||
#: escapes.py:5 | ||
msgid "" | ||
"\"\t\n" | ||
"\r\\" | ||
msgstr "" | ||
#: escapes.py:8 | ||
msgid "" | ||
"\000\001\002\003\004\005\006\007\010\t\n" | ||
"\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" | ||
msgstr "" | ||
#: escapes.py:13 | ||
msgid " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" | ||
msgstr "" | ||
#: escapes.py:17 | ||
msgid "\177" | ||
msgstr "" | ||
#: escapes.py:20 | ||
msgid "€  ÿ" | ||
msgstr "" | ||
#: escapes.py:23 | ||
msgid "α ㄱ 𓂀" | ||
msgstr "" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# SOME DESCRIPTIVE TITLE. | ||
# Copyright (C) YEAR ORGANIZATION | ||
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2000-01-01 00:00+0000\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" | ||
"Generated-By: pygettext.py 1.5\n" | ||
#: escapes.py:5 | ||
msgid "" | ||
"\"\t\n" | ||
"\r\\" | ||
msgstr "" | ||
#: escapes.py:8 | ||
msgid "" | ||
"\000\001\002\003\004\005\006\007\010\t\n" | ||
"\013\014\r\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" | ||
msgstr "" | ||
#: escapes.py:13 | ||
msgid " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~" | ||
msgstr "" | ||
#: escapes.py:17 | ||
msgid "\177" | ||
msgstr "" | ||
#: escapes.py:20 | ||
msgid "\302\200 \302\240 \303\277" | ||
msgstr "" | ||
#: escapes.py:23 | ||
msgid "\316\261 \343\204\261 \360\223\202\200" | ||
msgstr "" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import gettext as _ | ||
# Special characters that are always escaped in the POT file | ||
_('"\t\n\r\\') | ||
# All ascii characters 0-31 | ||
_('\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n' | ||
'\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15' | ||
'\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f') | ||
# All ascii characters 32-126 | ||
_(' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ' | ||
'[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~') | ||
# ascii char 127 | ||
_('\x7f') | ||
# some characters in the 128-255 range | ||
_('\x80 \xa0 ÿ') | ||
# some characters >= 256 encoded as 2, 3 and 4 bytes, respectively | ||
_('α ㄱ 𓂀') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -369,15 +369,8 @@ class _(object): | ||
def test_pygettext_output(self): | ||
"""Test that the pygettext output exactly matches snapshots.""" | ||
for input_file, output_file, output in extract_from_snapshots(): | ||
with self.subTest(input_file=input_file): | ||
expected = output_file.read_text(encoding='utf-8') | ||
self.assert_POT_equal(expected, output) | ||
@@ -408,15 +401,37 @@ def test_files_list(self): | ||
self.assertNotIn(text3, data) | ||
def extract_from_snapshots(): | ||
snapshots = { | ||
'messages.py': ('--docstrings',), | ||
'fileloc.py': ('--docstrings',), | ||
'docstrings.py': ('--docstrings',), | ||
# == Test character escaping | ||
# Escape ascii and unicode: | ||
'escapes.py': ('--escape',), | ||
# Escape only ascii and let unicode pass through: | ||
('escapes.py', 'ascii-escapes.pot'): (), | ||
} | ||
for filename, args in snapshots.items(): | ||
if isinstance(filename, tuple): | ||
filename, output_file = filename | ||
output_file = DATA_DIR / output_file | ||
input_file = DATA_DIR / filename | ||
else: | ||
input_file = DATA_DIR / filename | ||
output_file = input_file.with_suffix('.pot') | ||
Comment on lines +404 to +423 MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. This is almost exactly what we have on main, I just needed to update it a bit to e.g. remove some CLI options that only exist on main, otherwise it's identical. | ||
contents = input_file.read_bytes() | ||
with temp_cwd(None): | ||
Path(input_file.name).write_bytes(contents) | ||
assert_python_ok('-Xutf8', Test_pygettext.script, *args, | ||
input_file.name) | ||
yield (input_file, output_file, | ||
Path('messages.pot').read_text(encoding='utf-8')) | ||
def update_POT_snapshots(): | ||
for _, output_file, output in extract_from_snapshots(): | ||
output = normalize_POT_file(output) | ||
output_file.write_text(output, encoding='utf-8') | ||
Uh oh!
There was an error while loading.Please reload this page.