Skip to content

Commit 518dc94

Browse files
bpo-37335, test_c_locale_coercion: Remove unnecessary code (GH-14447)
Python initialization now ensures that sys stream encoding names are always normalized by codecs.lookup(encoding).name. Simplify test_c_locale_coercion: it doesn't have to normalize encoding names anymore. (cherry picked from commit 61bf97e) Co-authored-by: Jakub Kulík <[email protected]>
1 parent bd92b94 commit 518dc94

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

Lib/test/test_c_locale_coercion.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,28 +116,15 @@ def get_expected_details(cls, coercion_expected, fs_encoding, stream_encoding, e
116116
stream_info = 2*[_stream.format("surrogateescape")]
117117
# stderr should always use backslashreplace
118118
stream_info.append(_stream.format("backslashreplace"))
119-
expected_lang = env_vars.get("LANG", "not set").lower()
119+
expected_lang = env_vars.get("LANG", "not set")
120120
if coercion_expected:
121-
expected_lc_ctype = CLI_COERCION_TARGET.lower()
121+
expected_lc_ctype = CLI_COERCION_TARGET
122122
else:
123-
expected_lc_ctype = env_vars.get("LC_CTYPE", "not set").lower()
124-
expected_lc_all = env_vars.get("LC_ALL", "not set").lower()
123+
expected_lc_ctype = env_vars.get("LC_CTYPE", "not set")
124+
expected_lc_all = env_vars.get("LC_ALL", "not set")
125125
env_info = expected_lang, expected_lc_ctype, expected_lc_all
126126
return dict(cls(fs_encoding, *stream_info, *env_info)._asdict())
127127

128-
@staticmethod
129-
def _handle_output_variations(data):
130-
"""Adjust the output to handle platform specific idiosyncrasies
131-
132-
* Some platforms report ASCII as ANSI_X3.4-1968
133-
* Some platforms report ASCII as US-ASCII
134-
* Some platforms report UTF-8 instead of utf-8
135-
"""
136-
data = data.replace(b"ANSI_X3.4-1968", b"ascii")
137-
data = data.replace(b"US-ASCII", b"ascii")
138-
data = data.lower()
139-
return data
140-
141128
@classmethod
142129
def get_child_details(cls, env_vars):
143130
"""Retrieves fsencoding and standard stream details from a child process
@@ -157,8 +144,7 @@ def get_child_details(cls, env_vars):
157144
if not result.rc == 0:
158145
result.fail(py_cmd)
159146
# All subprocess outputs in this test case should be pure ASCII
160-
adjusted_output = cls._handle_output_variations(result.out)
161-
stdout_lines = adjusted_output.decode("ascii").splitlines()
147+
stdout_lines = result.out.decode("ascii").splitlines()
162148
child_encoding_details = dict(cls(*stdout_lines)._asdict())
163149
stderr_lines = result.err.decode("ascii").rstrip().splitlines()
164150
return child_encoding_details, stderr_lines
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove no longer necessary code from c locale coercion tests

0 commit comments

Comments
 (0)