MCPcopy Index your code
hub / github.com/python/cpython / test_forced_io_encoding

Method test_forced_io_encoding

Lib/test/test_embed.py:273–314  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

271 )
272
273 def test_forced_io_encoding(self):
274 # Checks forced configuration of embedded interpreter IO streams
275 env = dict(os.environ, PYTHONIOENCODING="utf-8:surrogateescape")
276 out, err = self.run_embedded_interpreter("test_forced_io_encoding", env=env)
277 if support.verbose > 1:
278 print()
279 print(out)
280 print(err)
281 expected_stream_encoding = "utf-8"
282 expected_errors = "surrogateescape"
283 expected_output = '\n'.join([
284 "--- Use defaults ---",
285 "Expected encoding: default",
286 "Expected errors: default",
287 "stdin: {in_encoding}:{errors}",
288 "stdout: {out_encoding}:{errors}",
289 "stderr: {out_encoding}:backslashreplace",
290 "--- Set errors only ---",
291 "Expected encoding: default",
292 "Expected errors: ignore",
293 "stdin: {in_encoding}:ignore",
294 "stdout: {out_encoding}:ignore",
295 "stderr: {out_encoding}:backslashreplace",
296 "--- Set encoding only ---",
297 "Expected encoding: iso8859-1",
298 "Expected errors: default",
299 "stdin: iso8859-1:{errors}",
300 "stdout: iso8859-1:{errors}",
301 "stderr: iso8859-1:backslashreplace",
302 "--- Set encoding and errors ---",
303 "Expected encoding: iso8859-1",
304 "Expected errors: replace",
305 "stdin: iso8859-1:replace",
306 "stdout: iso8859-1:replace",
307 "stderr: iso8859-1:backslashreplace"])
308 expected_output = expected_output.format(
309 in_encoding=expected_stream_encoding,
310 out_encoding=expected_stream_encoding,
311 errors=expected_errors)
312 # This is useful if we ever trip over odd platform behaviour
313 self.maxDiff = None
314 self.assertEqual(out.strip(), expected_output)
315
316 def test_pre_initialization_api(self):
317 """

Callers

nothing calls this directly

Calls 5

joinMethod · 0.45
formatMethod · 0.45
assertEqualMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected