File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1129,6 +1129,27 @@ def test_universal_newlines_communicate_encodings(self):
1129
1129
stdout , stderr = popen .communicate (input = '' )
1130
1130
self .assertEqual (stdout , '1\n 2\n 3\n 4' )
1131
1131
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
+
1132
1153
def test_communicate_errors (self ):
1133
1154
for errors , expected in [
1134
1155
('ignore' , '' ),
You can’t perform that action at this time.
0 commit comments