diff options
Diffstat (limited to 'Lib/test/test_c_locale_coercion.py')
-rw-r--r-- | Lib/test/test_c_locale_coercion.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/Lib/test/test_c_locale_coercion.py b/Lib/test/test_c_locale_coercion.py index 635c98f..2a22739 100644 --- a/Lib/test/test_c_locale_coercion.py +++ b/Lib/test/test_c_locale_coercion.py @@ -6,7 +6,6 @@ import os import sys import sysconfig import shutil -import subprocess from collections import namedtuple import test.support @@ -18,9 +17,12 @@ from test.support.script_helper import ( # Set our expectation for the default encoding used in the C locale # for the filesystem encoding and the standard streams -# AIX uses iso8859-1 in the C locale, other *nix platforms use ASCII +# While most *nix platforms default to ASCII in the C locale, some use a +# different encoding. if sys.platform.startswith("aix"): C_LOCALE_STREAM_ENCODING = "iso8859-1" +elif test.support.is_android: + C_LOCALE_STREAM_ENCODING = "utf-8" else: C_LOCALE_STREAM_ENCODING = "ascii" @@ -301,6 +303,19 @@ class LocaleCoercionTests(_LocaleHandlingTestCase): # See https://bugs.python.org/issue30672 for discussion if locale_to_set == "POSIX": continue + + # Platforms using UTF-8 in the C locale do not print + # CLI_COERCION_WARNING when all the locale envt variables are + # not set or set to the empty string. + _expected_warnings = expected_warnings + for _env_var in base_var_dict: + if base_var_dict[_env_var]: + break + else: + if (C_LOCALE_STREAM_ENCODING == "utf-8" and + locale_to_set == "" and coerce_c_locale == "warn"): + _expected_warnings = None + with self.subTest(env_var=env_var, nominal_locale=locale_to_set, PYTHONCOERCECLOCALE=coerce_c_locale): @@ -312,7 +327,7 @@ class LocaleCoercionTests(_LocaleHandlingTestCase): self._check_child_encoding_details(var_dict, fs_encoding, stream_encoding, - expected_warnings, + _expected_warnings, coercion_expected) def test_test_PYTHONCOERCECLOCALE_not_set(self): |