MCPcopy Create free account
hub / github.com/python/cpython / setUpModule

Function setUpModule

Lib/test/test_c_locale_coercion.py:182–209  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

180CLI_COERCION_WARNING = None
181
182def setUpModule():
183 global AVAILABLE_TARGETS
184 global CLI_COERCION_TARGET
185 global CLI_COERCION_WARNING
186
187 if AVAILABLE_TARGETS is not None:
188 # initialization already done
189 return
190 AVAILABLE_TARGETS = []
191
192 # Find the target locales available in the current system
193 for target_locale in _C_UTF8_LOCALES:
194 if _set_locale_in_subprocess(target_locale):
195 AVAILABLE_TARGETS.append(target_locale)
196
197 if AVAILABLE_TARGETS:
198 # Coercion is expected to use the first available target locale
199 CLI_COERCION_TARGET = AVAILABLE_TARGETS[0]
200 CLI_COERCION_WARNING = CLI_COERCION_WARNING_FMT.format(CLI_COERCION_TARGET)
201
202 if support.verbose:
203 print(f"AVAILABLE_TARGETS = {AVAILABLE_TARGETS!r}")
204 print(f"EXPECTED_C_LOCALE_EQUIVALENTS = {EXPECTED_C_LOCALE_EQUIVALENTS!r}")
205 print(f"EXPECTED_C_LOCALE_STREAM_ENCODING = {EXPECTED_C_LOCALE_STREAM_ENCODING!r}")
206 print(f"EXPECTED_C_LOCALE_FS_ENCODING = {EXPECTED_C_LOCALE_FS_ENCODING!r}")
207 print(f"EXPECT_COERCION_IN_DEFAULT_LOCALE = {EXPECT_COERCION_IN_DEFAULT_LOCALE!r}")
208 print(f"_C_UTF8_LOCALES = {_C_UTF8_LOCALES!r}")
209 print(f"_check_nl_langinfo_CODESET = {_check_nl_langinfo_CODESET!r}")
210
211
212class _LocaleHandlingTestCase(unittest.TestCase):

Callers

nothing calls this directly

Calls 3

appendMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…