@@ -85,15 +85,6 @@ def tearDown(self):
8585 self .doCleanups ()
8686 support .reap_children ()
8787
88- def assertStderrEqual (self , stderr , expected , msg = None ):
89- # In a debug build, stuff like "[6580 refs]" is printed to stderr at
90- # shutdown time. That frustrates tests trying to check stderr produced
91- # from a spawned Python process.
92- actual = support .strip_python_stderr (stderr )
93- # strip_python_stderr also strips whitespace, so we do too.
94- expected = expected .strip ()
95- self .assertEqual (actual , expected , msg )
96-
9788
9889class PopenTestException (Exception ):
9990 pass
@@ -547,7 +538,7 @@ def test_stderr_pipe(self):
547538 'import sys; sys.stderr.write("strawberry")' ],
548539 stderr = subprocess .PIPE )
549540 with p :
550- self .assertStderrEqual (p .stderr .read (), b"strawberry" )
541+ self .assertEqual (p .stderr .read (), b"strawberry" )
551542
552543 def test_stderr_filedes (self ):
553544 # stderr is set to open file descriptor
@@ -559,7 +550,7 @@ def test_stderr_filedes(self):
559550 stderr = d )
560551 p .wait ()
561552 os .lseek (d , 0 , 0 )
562- self .assertStderrEqual (os .read (d , 1024 ), b"strawberry" )
553+ self .assertEqual (os .read (d , 1024 ), b"strawberry" )
563554
564555 def test_stderr_fileobj (self ):
565556 # stderr is set to open file object
@@ -570,7 +561,7 @@ def test_stderr_fileobj(self):
570561 stderr = tf )
571562 p .wait ()
572563 tf .seek (0 )
573- self .assertStderrEqual (tf .read (), b"strawberry" )
564+ self .assertEqual (tf .read (), b"strawberry" )
574565
575566 def test_stderr_redirect_with_no_stdout_redirect (self ):
576567 # test stderr=STDOUT while stdout=None (not set)
@@ -589,8 +580,8 @@ def test_stderr_redirect_with_no_stdout_redirect(self):
589580 stderr = subprocess .PIPE )
590581 stdout , stderr = p .communicate ()
591582 #NOTE: stdout should get stderr from grandchild
592- self .assertStderrEqual (stdout , b'42' )
593- self .assertStderrEqual (stderr , b'' ) # should be empty
583+ self .assertEqual (stdout , b'42' )
584+ self .assertEqual (stderr , b'' ) # should be empty
594585 self .assertEqual (p .returncode , 0 )
595586
596587 def test_stdout_stderr_pipe (self ):
@@ -603,7 +594,7 @@ def test_stdout_stderr_pipe(self):
603594 stdout = subprocess .PIPE ,
604595 stderr = subprocess .STDOUT )
605596 with p :
606- self .assertStderrEqual (p .stdout .read (), b"appleorange" )
597+ self .assertEqual (p .stdout .read (), b"appleorange" )
607598
608599 def test_stdout_stderr_file (self ):
609600 # capture stdout and stderr to the same open file
@@ -618,7 +609,7 @@ def test_stdout_stderr_file(self):
618609 stderr = tf )
619610 p .wait ()
620611 tf .seek (0 )
621- self .assertStderrEqual (tf .read (), b"appleorange" )
612+ self .assertEqual (tf .read (), b"appleorange" )
622613
623614 def test_stdout_filedes_of_stdout (self ):
624615 # stdout is set to 1 (#1531862).
@@ -767,7 +758,7 @@ def test_communicate_stderr(self):
767758 stderr = subprocess .PIPE )
768759 (stdout , stderr ) = p .communicate ()
769760 self .assertEqual (stdout , None )
770- self .assertStderrEqual (stderr , b"pineapple" )
761+ self .assertEqual (stderr , b"pineapple" )
771762
772763 def test_communicate (self ):
773764 p = subprocess .Popen ([sys .executable , "-c" ,
@@ -782,7 +773,7 @@ def test_communicate(self):
782773 self .addCleanup (p .stdin .close )
783774 (stdout , stderr ) = p .communicate (b"banana" )
784775 self .assertEqual (stdout , b"banana" )
785- self .assertStderrEqual (stderr , b"pineapple" )
776+ self .assertEqual (stderr , b"pineapple" )
786777
787778 def test_communicate_timeout (self ):
788779 p = subprocess .Popen ([sys .executable , "-c" ,
@@ -801,7 +792,7 @@ def test_communicate_timeout(self):
801792 # after it completes.
802793 (stdout , stderr ) = p .communicate ()
803794 self .assertEqual (stdout , "banana" )
804- self .assertStderrEqual (stderr .encode (), b"pineapple\n pear\n " )
795+ self .assertEqual (stderr .encode (), b"pineapple\n pear\n " )
805796
806797 def test_communicate_timeout_large_output (self ):
807798 # Test an expiring timeout while the child is outputting lots of data.
@@ -887,7 +878,7 @@ def test_writes_before_communicate(self):
887878 p .stdin .write (b"banana" )
888879 (stdout , stderr ) = p .communicate (b"split" )
889880 self .assertEqual (stdout , b"bananasplit" )
890- self .assertStderrEqual (stderr , b"" )
881+ self .assertEqual (stderr , b"" )
891882
892883 def test_universal_newlines_and_text (self ):
893884 args = [
@@ -1005,7 +996,6 @@ def test_universal_newlines_communicate_stdin_stdout_stderr(self):
1005996 self .assertEqual ("line1\n line2\n line3\n line4\n line5\n " , stdout )
1006997 # Python debug build push something like "[42442 refs]\n"
1007998 # to stderr at exit of subprocess.
1008- # Don't use assertStderrEqual because it strips CR and LF from output.
1009999 self .assertTrue (stderr .startswith ("eline2\n eline6\n eline7\n " ))
10101000
10111001 def test_universal_newlines_communicate_encodings (self ):
@@ -2240,13 +2230,13 @@ def test_send_signal(self):
22402230 def test_kill (self ):
22412231 p = self ._kill_process ('kill' )
22422232 _ , stderr = p .communicate ()
2243- self .assertStderrEqual (stderr , b'' )
2233+ self .assertEqual (stderr , b'' )
22442234 self .assertEqual (p .wait (), - signal .SIGKILL )
22452235
22462236 def test_terminate (self ):
22472237 p = self ._kill_process ('terminate' )
22482238 _ , stderr = p .communicate ()
2249- self .assertStderrEqual (stderr , b'' )
2239+ self .assertEqual (stderr , b'' )
22502240 self .assertEqual (p .wait (), - signal .SIGTERM )
22512241
22522242 def test_send_signal_dead (self ):
@@ -2294,8 +2284,8 @@ def check_close_std_fds(self, fds):
22942284 stdin = stdin ,
22952285 stdout = subprocess .PIPE ,
22962286 stderr = subprocess .PIPE ).communicate ()
2297- err = support . strip_python_stderr ( err )
2298- self .assertEqual (( out , err ), ( b'apple' , b' orange') )
2287+ self . assertEqual ( out , b'apple' )
2288+ self .assertEqual (err , b' orange' )
22992289 finally :
23002290 self ._restore_fds (saved_fds )
23012291
@@ -2380,7 +2370,7 @@ def test_remapping_std_fds(self):
23802370 os .lseek (fd , 0 , 0 )
23812371
23822372 out = os .read (temp_fds [2 ], 1024 )
2383- err = support . strip_python_stderr ( os .read (temp_fds [0 ], 1024 ))
2373+ err = os .read (temp_fds [0 ], 1024 ). strip ( )
23842374 self .assertEqual (out , b"got STDIN" )
23852375 self .assertEqual (err , b"err" )
23862376
@@ -2422,7 +2412,7 @@ def check_swap_fds(self, stdin_no, stdout_no, stderr_no):
24222412 os .lseek (fd , 0 , 0 )
24232413
24242414 out = os .read (stdout_no , 1024 )
2425- err = support . strip_python_stderr ( os .read (stderr_no , 1024 ))
2415+ err = os .read (stderr_no , 1024 ). strip ( )
24262416 finally :
24272417 self ._restore_fds (saved_fds )
24282418
@@ -3338,7 +3328,7 @@ def _kill_process(self, method, *args):
33383328 p .stdout .read (1 )
33393329 getattr (p , method )(* args )
33403330 _ , stderr = p .communicate ()
3341- self .assertStderrEqual (stderr , b'' )
3331+ self .assertEqual (stderr , b'' )
33423332 returncode = p .wait ()
33433333 self .assertNotEqual (returncode , 0 )
33443334
@@ -3361,7 +3351,7 @@ def _kill_dead_process(self, method, *args):
33613351 # This shouldn't raise even though the child is now dead
33623352 getattr (p , method )(* args )
33633353 _ , stderr = p .communicate ()
3364- self .assertStderrEqual (stderr , b'' )
3354+ self .assertEqual (stderr , b'' )
33653355 rc = p .wait ()
33663356 self .assertEqual (rc , 42 )
33673357
@@ -3550,7 +3540,7 @@ def test_pipe(self):
35503540 stdout = subprocess .PIPE ,
35513541 stderr = subprocess .PIPE ) as proc :
35523542 self .assertEqual (proc .stdout .read (), b"stdout" )
3553- self .assertStderrEqual (proc .stderr .read (), b"stderr" )
3543+ self .assertEqual (proc .stderr .read (), b"stderr" )
35543544
35553545 self .assertTrue (proc .stdout .closed )
35563546 self .assertTrue (proc .stderr .closed )
0 commit comments