Skip to content

Commit 7c2d570

Browse files
authored
bpo-35290: Add debug info to test_c_locale_coercion (GH-10631)
In verbose mode, test_c_locale_coercion now dumps global variables at startup.
1 parent d936a8f commit 7c2d570

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Lib/test/test_c_locale_coercion.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import shutil
99
from collections import namedtuple
1010

11-
import test.support
11+
from test import support
1212
from test.support.script_helper import (
1313
run_python_until_end,
1414
interpreter_requires_environment,
@@ -27,7 +27,7 @@
2727

2828
# Apply some platform dependent overrides
2929
if sys.platform.startswith("linux"):
30-
if test.support.is_android:
30+
if support.is_android:
3131
# Android defaults to using UTF-8 for all system interfaces
3232
EXPECTED_C_LOCALE_STREAM_ENCODING = "utf-8"
3333
EXPECTED_C_LOCALE_FS_ENCODING = "utf-8"
@@ -203,6 +203,15 @@ def setUpModule():
203203
CLI_COERCION_TARGET = AVAILABLE_TARGETS[0]
204204
CLI_COERCION_WARNING = CLI_COERCION_WARNING_FMT.format(CLI_COERCION_TARGET)
205205

206+
if support.verbose:
207+
print(f"AVAILABLE_TARGETS = {AVAILABLE_TARGETS!r}")
208+
print(f"EXPECTED_C_LOCALE_EQUIVALENTS = {EXPECTED_C_LOCALE_EQUIVALENTS!r}")
209+
print(f"EXPECTED_C_LOCALE_STREAM_ENCODING = {EXPECTED_C_LOCALE_STREAM_ENCODING!r}")
210+
print(f"EXPECTED_C_LOCALE_FS_ENCODING = {EXPECTED_C_LOCALE_FS_ENCODING!r}")
211+
print(f"EXPECT_COERCION_IN_DEFAULT_LOCALE = {EXPECT_COERCION_IN_DEFAULT_LOCALE!r}")
212+
print(f"_C_UTF8_LOCALES = {_C_UTF8_LOCALES!r}")
213+
print(f"_check_nl_langinfo_CODESET = {_check_nl_langinfo_CODESET!r}")
214+
206215

207216
class _LocaleHandlingTestCase(unittest.TestCase):
208217
# Base class to check expected locale handling behaviour
@@ -279,7 +288,7 @@ def test_external_target_locale_configuration(self):
279288

280289

281290

282-
@test.support.cpython_only
291+
@support.cpython_only
283292
@unittest.skipUnless(sysconfig.get_config_var("PY_COERCE_C_LOCALE"),
284293
"C locale coercion disabled at build time")
285294
class LocaleCoercionTests(_LocaleHandlingTestCase):
@@ -335,7 +344,7 @@ def _check_c_locale_coercion(self,
335344
# locale environment variables are undefined or empty. When
336345
# this code path is run with environ['LC_ALL'] == 'C', then
337346
# LEGACY_LOCALE_WARNING is printed.
338-
if (test.support.is_android and
347+
if (support.is_android and
339348
_expected_warnings == [CLI_COERCION_WARNING]):
340349
_expected_warnings = None
341350
self._check_child_encoding_details(base_var_dict,
@@ -405,11 +414,11 @@ def test_LC_ALL_set_to_C(self):
405414
coercion_expected=False)
406415

407416
def test_main():
408-
test.support.run_unittest(
417+
support.run_unittest(
409418
LocaleConfigurationTests,
410419
LocaleCoercionTests
411420
)
412-
test.support.reap_children()
421+
support.reap_children()
413422

414423
if __name__ == "__main__":
415424
test_main()

0 commit comments

Comments
 (0)