@@ -2813,7 +2813,8 @@ def _run_child(self, child, terminal_input):
28132813 def check_input_tty (self , prompt , terminal_input , stdio_encoding = None , * ,
28142814 expected = None ,
28152815 stdin_errors = 'surrogateescape' ,
2816- stdout_errors = 'replace' ):
2816+ stdout_errors = 'replace' ,
2817+ terminal_input_end = b'\r \n ' ):
28172818 if not sys .stdin .isatty () or not sys .stdout .isatty ():
28182819 self .skipTest ("stdin and stdout must be ttys" )
28192820 def child (wpipe ):
@@ -2831,7 +2832,7 @@ def child(wpipe):
28312832 except BaseException as e :
28322833 print (ascii (f'{ e .__class__ .__name__ } : { e !s} ' ), file = wpipe )
28332834 with self .detach_readline ():
2834- lines = self .run_child (child , terminal_input + b" \r \n " )
2835+ lines = self .run_child (child , terminal_input + terminal_input_end )
28352836 # Check we did exercise the GNU readline path
28362837 self .assertIn (lines [0 ], {'tty = True' , 'tty = False' })
28372838 if lines [0 ] != 'tty = True' :
@@ -2869,6 +2870,9 @@ def test_input_tty(self):
28692870 # Test input() functionality when wired to a tty
28702871 self .check_input_tty ("prompt" , b"quux" )
28712872
2873+ def test_input_tty_eof_without_newline (self ):
2874+ self .check_input_tty ("prompt" , b"quux" , terminal_input_end = b"\x04 " )
2875+
28722876 def test_input_tty_non_ascii (self ):
28732877 # Check stdin/stdout encoding is used when invoking PyOS_Readline()
28742878 self .check_input_tty ("prompté" , b"quux\xc3 \xa9 " , "utf-8" )
0 commit comments