@@ -586,27 +586,29 @@ def test_for_crash_traceback_with_redirected_stdout(self):
586586 script_command = "print('script has run')"
587587 with TemporaryDirectory () as tmp_dir :
588588 stdout_path = os .path .join (tmp_dir , "WinCMDLineTests.txt" )
589- with open (stdout_path , "w" ) as stdout_file , \
589+ with open (stdout_path , "w+ " ) as stdout_file , \
590590 subprocess .Popen (
591- [sys .executable , '-i' , '-c' , script_command ],
591+ [sys .executable , '-i' , '-u' , '- c' , script_command ],
592592 stdin = None ,
593593 stdout = stdout_file ,
594594 stderr = subprocess .PIPE ,
595595 text = True , errors = 'replace'
596596 ) as process :
597597 stderr_output = ""
598598 try :
599- process .wait (timeout = 3 )
599+ process .wait (timeout = 5 )
600600 except subprocess .TimeoutExpired :
601601 process .kill ()
602602 _ , stderr_output = process .communicate ()
603- has_crash_traceback = (
604- "OSError " in stderr_output and
605- len (stderr_output ) > 1200
603+ isOK = (
604+ ">>> " in stderr_output and
605+ len (stderr_output ) < 1200
606606 )
607- if has_crash_traceback :
608- self .fail ("Detected endless OSError traceback."
609- f"\n --- stderr ---\n { stderr_output [:1200 ]} " )
607+ stdout_file .seek (0 )
608+ stdout_from_file = stdout_file .read ()
609+ stdout_file .close ()
610+ self .assertEqual (isOK , True )
611+ self .assertIn ("script has run" , stdout_from_file )
610612
611613
612614if __name__ == "__main__" :
0 commit comments