File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1129,6 +1129,27 @@ def test_universal_newlines_communicate_encodings(self):
11291129 stdout , stderr = popen .communicate (input = '' )
11301130 self .assertEqual (stdout , '1\n 2\n 3\n 4' )
11311131
1132+ def test_universal_newlines_timeout (self ):
1133+ with self .assertRaises (subprocess .TimeoutExpired ) as c :
1134+ p = subprocess .run (
1135+ [
1136+ sys .executable , "-c" ,
1137+ "import sys, time;"
1138+ r"sys.stderr.buffer.write(b'foo \xc2\xa4 bar');"
1139+ "sys.stderr.buffer.flush();"
1140+ r"sys.stdout.buffer.write(b'foo \xc2');"
1141+ "sys.stdout.buffer.flush();"
1142+ "time.sleep(0.1);"
1143+ r"sys.stdout.buffer.write(b'\xa4 bar');"
1144+ "sys.stdout.buffer.flush();"
1145+ ],
1146+ stdout = subprocess .PIPE ,
1147+ stderr = subprocess .PIPE ,
1148+ universal_newlines = True ,
1149+ timeout = 0.05 )
1150+ self .assertEqual (c .exception .stdout , "foo " )
1151+ self .assertEqual (c .exception .stderr , "foo ¤ bar" )
1152+
11321153 def test_communicate_errors (self ):
11331154 for errors , expected in [
11341155 ('ignore' , '' ),
You can’t perform that action at this time.
0 commit comments