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

Method test_stdio

Lib/test/test_utf8_mode.py:123–151  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

121 self.assertEqual(out, 'mbcs/replace')
122
123 def test_stdio(self):
124 code = textwrap.dedent('''
125 import sys
126 print(f"stdin: {sys.stdin.encoding}/{sys.stdin.errors}")
127 print(f"stdout: {sys.stdout.encoding}/{sys.stdout.errors}")
128 print(f"stderr: {sys.stderr.encoding}/{sys.stderr.errors}")
129 ''')
130
131 out = self.get_output('-X', 'utf8', '-c', code,
132 PYTHONIOENCODING='')
133 self.assertEqual(out.splitlines(),
134 ['stdin: utf-8/surrogateescape',
135 'stdout: utf-8/surrogateescape',
136 'stderr: utf-8/backslashreplace'])
137
138 # PYTHONIOENCODING has the priority over PYTHONUTF8
139 out = self.get_output('-X', 'utf8', '-c', code,
140 PYTHONIOENCODING="latin1")
141 self.assertEqual(out.splitlines(),
142 ['stdin: iso8859-1/strict',
143 'stdout: iso8859-1/strict',
144 'stderr: iso8859-1/backslashreplace'])
145
146 out = self.get_output('-X', 'utf8', '-c', code,
147 PYTHONIOENCODING=":namereplace")
148 self.assertEqual(out.splitlines(),
149 ['stdin: utf-8/namereplace',
150 'stdout: utf-8/namereplace',
151 'stderr: utf-8/backslashreplace'])
152
153 def test_io(self):
154 code = textwrap.dedent('''

Callers

nothing calls this directly

Calls 4

get_outputMethod · 0.95
dedentMethod · 0.45
assertEqualMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected