Skip to content

Commit 563f9ec

Browse files
CPython Developersyouknowone
authored andcommitted
Update test_repl from cpython 3.10.6
1 parent 2539e82 commit 563f9ec

1 file changed

Lines changed: 20 additions & 6 deletions

File tree

Lib/test/test_repl.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def spawn_repl(*args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kw):
2929
# test.support.script_helper.
3030
env = kw.setdefault('env', dict(os.environ))
3131
env['TERM'] = 'vt100'
32-
return subprocess.Popen(cmd_line, executable=sys.executable,
32+
return subprocess.Popen(cmd_line,
33+
executable=sys.executable,
34+
text=True,
3335
stdin=subprocess.PIPE,
3436
stdout=stdout, stderr=stderr,
3537
**kw)
@@ -49,12 +51,11 @@ def test_no_memory(self):
4951
sys.exit(0)
5052
"""
5153
user_input = dedent(user_input)
52-
user_input = user_input.encode()
5354
p = spawn_repl()
5455
with SuppressCrashReport():
5556
p.stdin.write(user_input)
5657
output = kill_python(p)
57-
self.assertIn(b'After the exception.', output)
58+
self.assertIn('After the exception.', output)
5859
# Exit code 120: Py_FinalizeEx() failed to flush stdout and stderr.
5960
self.assertIn(p.returncode, (1, 120))
6061

@@ -86,13 +87,26 @@ def test_multiline_string_parsing(self):
8687
</test>"""
8788
'''
8889
user_input = dedent(user_input)
89-
user_input = user_input.encode()
9090
p = spawn_repl()
91-
with SuppressCrashReport():
92-
p.stdin.write(user_input)
91+
p.stdin.write(user_input)
9392
output = kill_python(p)
9493
self.assertEqual(p.returncode, 0)
9594

95+
def test_close_stdin(self):
96+
user_input = dedent('''
97+
import os
98+
print("before close")
99+
os.close(0)
100+
''')
101+
prepare_repl = dedent('''
102+
from test.support import suppress_msvcrt_asserts
103+
suppress_msvcrt_asserts()
104+
''')
105+
process = spawn_repl('-c', prepare_repl)
106+
output = process.communicate(user_input)[0]
107+
self.assertEqual(process.returncode, 0)
108+
self.assertIn('before close', output)
109+
96110

97111
if __name__ == "__main__":
98112
unittest.main()

0 commit comments

Comments
 (0)