@@ -32,6 +32,12 @@ def _kill_python_and_exit_code(p):
3232 return data , returncode
3333
3434
35+ b_deprecation_msg = (
36+ '-b option is deprecated since Python 3.15 '
37+ 'and will be removed in Python 3.17'
38+ )
39+
40+
3541class CmdLineTest (unittest .TestCase ):
3642 def test_directories (self ):
3743 assert_python_failure ('.' )
@@ -706,7 +712,7 @@ def run_xdev(self, *args, check_exitcode=True, xdev=True):
706712 env = env )
707713 if check_exitcode :
708714 self .assertEqual (proc .returncode , 0 , proc )
709- return proc .stdout . rstrip ( )
715+ return self . maybe_remove_b_deprecation_msg ( proc .stdout )
710716
711717 @support .cpython_only
712718 def test_xdev (self ):
@@ -789,7 +795,22 @@ def check_warnings_filters(self, cmdline_option, envvar, use_pywarning=False):
789795 universal_newlines = True ,
790796 env = env )
791797 self .assertEqual (proc .returncode , 0 , proc )
792- return proc .stdout .rstrip ()
798+ return self .maybe_remove_b_deprecation_msg (proc .stdout )
799+
800+ def maybe_remove_b_deprecation_msg (self , output ):
801+ return output .replace (b_deprecation_msg + '\n ' , '' ).rstrip ()
802+
803+ def test_b_deprecation_msg_stderr (self ):
804+ for arg in ['-b' , '-bb' ]:
805+ with self .subTest (arg = arg ):
806+ args = (sys .executable , arg , '-c' , '' )
807+ proc = subprocess .run (args ,
808+ stdout = subprocess .PIPE ,
809+ stderr = subprocess .PIPE ,
810+ universal_newlines = True )
811+ self .assertEqual (proc .returncode , 0 , proc )
812+ self .assertEqual (proc .stdout , '' )
813+ self .assertEqual (proc .stderr .rstrip (), b_deprecation_msg )
793814
794815 def test_warnings_filter_precedence (self ):
795816 expected_filters = ("error::BytesWarning "
0 commit comments