bpo-28180: assume UTF-8 for Mac OS X PEP 538 tests (GH-2130) · python/cpython@4563099 (original) (raw)
`@@ -14,6 +14,17 @@
`
14
14
`interpreter_requires_environment,
`
15
15
`)
`
16
16
``
``
17
`+
Set our expectation for the default encoding used in the C locale
`
``
18
`+
for the filesystem encoding and the standard streams
`
``
19
`+
if sys.platform == "darwin":
`
``
20
`+
EXPECTED_C_LOCALE_FSENCODING = "utf-8"
`
``
21
`+
else:
`
``
22
`+
EXPECTED_C_LOCALE_FSENCODING = "ascii"
`
``
23
+
``
24
`+
XXX (ncoghlan): The above is probably still wrong for:
`
``
25
`+
* Windows when PYTHONLEGACYWINDOWSFSENCODING is set
`
``
26
`+
* AIX and any other platforms that use latin-1 in the C locale
`
``
27
+
17
28
`# In order to get the warning messages to match up as expected, the candidate
`
18
29
`# order here must much the target locale order in Python/pylifecycle.c
`
19
30
`_C_UTF8_LOCALES = ("C.UTF-8", "C.utf8", "UTF-8")
`
`@@ -134,7 +145,7 @@ def test_library_c_locale_warning(self):
`
134
145
` }
`
135
146
`with self.subTest(forced_locale=locale_to_set):
`
136
147
`self._check_child_encoding_details(var_dict,
`
137
``
`-
"ascii",
`
``
148
`+
EXPECTED_C_LOCALE_FSENCODING,
`
138
149
` [LIBRARY_C_LOCALE_WARNING])
`
139
150
``
140
151
`# Details of the CLI locale coercion warning emitted at runtime
`
`@@ -158,14 +169,16 @@ def setUpModule():
`
158
169
`for target_locale in _C_UTF8_LOCALES:
`
159
170
`if _set_locale_in_subprocess(target_locale):
`
160
171
`AVAILABLE_TARGETS.append(target_locale)
`
161
``
`-
if not AVAILABLE_TARGETS:
`
162
``
`-
raise unittest.SkipTest("No C-with-UTF-8 locale available")
`
163
172
``
164
173
``
165
174
``
166
175
`class _LocaleCoercionTargetsTestCase(_ChildProcessEncodingTestCase):
`
167
176
`# Base class for test cases that rely on coercion targets being defined
`
168
``
`-
pass
`
``
177
+
``
178
`+
@classmethod
`
``
179
`+
def setUpClass(cls):
`
``
180
`+
if not AVAILABLE_TARGETS:
`
``
181
`+
raise unittest.SkipTest("No C-with-UTF-8 locale available")
`
169
182
``
170
183
``
171
184
`class LocaleConfigurationTests(_LocaleCoercionTargetsTestCase):
`
`@@ -186,6 +199,11 @@ def test_external_target_locale_configuration(self):
`
186
199
` }
`
187
200
`for env_var in ("LANG", "LC_CTYPE"):
`
188
201
`for locale_to_set in AVAILABLE_TARGETS:
`
``
202
`+
XXX (ncoghlan): LANG=UTF-8 doesn't appear to work as
`
``
203
`+
expected, so skip that combination for now
`
``
204
`+
if env_var == "LANG" and locale_to_set == "UTF-8":
`
``
205
`+
continue
`
``
206
+
189
207
`with self.subTest(env_var=env_var,
`
190
208
`configured_locale=locale_to_set):
`
191
209
`var_dict = base_var_dict.copy()
`
`@@ -251,7 +269,8 @@ def test_PYTHONCOERCECLOCALE_not_zero(self):
`
251
269
``
252
270
`def test_PYTHONCOERCECLOCALE_set_to_zero(self):
`
253
271
`# The setting "0" should result in the locale coercion being disabled
`
254
``
`-
self._check_c_locale_coercion("ascii", coerce_c_locale="0")
`
``
272
`+
self._check_c_locale_coercion(EXPECTED_C_LOCALE_FSENCODING,
`
``
273
`+
coerce_c_locale="0")
`
255
274
``
256
275
``
257
276
`def test_main():
`