Issue #19977: Fix test_capi when LC_CTYPE locale is POSIX
This commit is contained in:
parent
97f17a784a
commit
b2bef62e91
|
@ -319,34 +319,38 @@ class EmbeddingTests(unittest.TestCase):
|
||||||
print()
|
print()
|
||||||
print(out)
|
print(out)
|
||||||
print(err)
|
print(err)
|
||||||
|
expected_errors = sys.__stdout__.errors
|
||||||
expected_stdin_encoding = sys.__stdin__.encoding
|
expected_stdin_encoding = sys.__stdin__.encoding
|
||||||
expected_pipe_encoding = self._get_default_pipe_encoding()
|
expected_pipe_encoding = self._get_default_pipe_encoding()
|
||||||
expected_output = os.linesep.join([
|
expected_output = os.linesep.join([
|
||||||
"--- Use defaults ---",
|
"--- Use defaults ---",
|
||||||
"Expected encoding: default",
|
"Expected encoding: default",
|
||||||
"Expected errors: default",
|
"Expected errors: default",
|
||||||
"stdin: {0}:strict",
|
"stdin: {in_encoding}:{errors}",
|
||||||
"stdout: {1}:strict",
|
"stdout: {out_encoding}:{errors}",
|
||||||
"stderr: {1}:backslashreplace",
|
"stderr: {out_encoding}:backslashreplace",
|
||||||
"--- Set errors only ---",
|
"--- Set errors only ---",
|
||||||
"Expected encoding: default",
|
"Expected encoding: default",
|
||||||
"Expected errors: surrogateescape",
|
"Expected errors: ignore",
|
||||||
"stdin: {0}:surrogateescape",
|
"stdin: {in_encoding}:ignore",
|
||||||
"stdout: {1}:surrogateescape",
|
"stdout: {out_encoding}:ignore",
|
||||||
"stderr: {1}:backslashreplace",
|
"stderr: {out_encoding}:backslashreplace",
|
||||||
"--- Set encoding only ---",
|
"--- Set encoding only ---",
|
||||||
"Expected encoding: latin-1",
|
"Expected encoding: latin-1",
|
||||||
"Expected errors: default",
|
"Expected errors: default",
|
||||||
"stdin: latin-1:strict",
|
"stdin: latin-1:{errors}",
|
||||||
"stdout: latin-1:strict",
|
"stdout: latin-1:{errors}",
|
||||||
"stderr: latin-1:backslashreplace",
|
"stderr: latin-1:backslashreplace",
|
||||||
"--- Set encoding and errors ---",
|
"--- Set encoding and errors ---",
|
||||||
"Expected encoding: latin-1",
|
"Expected encoding: latin-1",
|
||||||
"Expected errors: surrogateescape",
|
"Expected errors: replace",
|
||||||
"stdin: latin-1:surrogateescape",
|
"stdin: latin-1:replace",
|
||||||
"stdout: latin-1:surrogateescape",
|
"stdout: latin-1:replace",
|
||||||
"stderr: latin-1:backslashreplace"]).format(expected_stdin_encoding,
|
"stderr: latin-1:backslashreplace"])
|
||||||
expected_pipe_encoding)
|
expected_output = expected_output.format(
|
||||||
|
in_encoding=expected_stdin_encoding,
|
||||||
|
out_encoding=expected_pipe_encoding,
|
||||||
|
errors=expected_errors)
|
||||||
# This is useful if we ever trip over odd platform behaviour
|
# This is useful if we ever trip over odd platform behaviour
|
||||||
self.maxDiff = None
|
self.maxDiff = None
|
||||||
self.assertEqual(out.strip(), expected_output)
|
self.assertEqual(out.strip(), expected_output)
|
||||||
|
|
|
@ -109,11 +109,11 @@ static void test_forced_io_encoding(void)
|
||||||
printf("--- Use defaults ---\n");
|
printf("--- Use defaults ---\n");
|
||||||
check_stdio_details(NULL, NULL);
|
check_stdio_details(NULL, NULL);
|
||||||
printf("--- Set errors only ---\n");
|
printf("--- Set errors only ---\n");
|
||||||
check_stdio_details(NULL, "surrogateescape");
|
check_stdio_details(NULL, "ignore");
|
||||||
printf("--- Set encoding only ---\n");
|
printf("--- Set encoding only ---\n");
|
||||||
check_stdio_details("latin-1", NULL);
|
check_stdio_details("latin-1", NULL);
|
||||||
printf("--- Set encoding and errors ---\n");
|
printf("--- Set encoding and errors ---\n");
|
||||||
check_stdio_details("latin-1", "surrogateescape");
|
check_stdio_details("latin-1", "replace");
|
||||||
|
|
||||||
/* Check calling after initialization fails */
|
/* Check calling after initialization fails */
|
||||||
Py_Initialize();
|
Py_Initialize();
|
||||||
|
|
Loading…
Reference in New Issue