File tree Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Expand file tree Collapse file tree 1 file changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -3230,18 +3230,14 @@ def f(x: int) -> int:
32303230                    with  self .subTest (flags = args ):
32313231                        self .invoke_ast (* args )
32323232
3233-     def  test_unknown_flag (self ):
3234-         with  self .assertRaises (SystemExit ):
3235-             output  =  self .invoke_ast ('--unknown' )
3236-             self .assertStartsWith (output , 'usage: ' )
3237- 
3238-     def  test_help_flag (self ):
3239-         # test 'python -m ast -h/--help' 
3240-         for  flag  in  ('-h' , '--help' ):
3233+     def  test_help_message (self ):
3234+         for  flag  in  ('-h' , '--help' , '--unknown' ):
32413235            with  self .subTest (flag = flag ):
3236+                 output  =  StringIO ()
32423237                with  self .assertRaises (SystemExit ):
3243-                     output  =  self .invoke_ast (flag )
3244-                     self .assertStartsWith (output , 'usage: ' )
3238+                     with  contextlib .redirect_stderr (output ):
3239+                         ast .main (args = (flag ))
3240+                 self .assertStartsWith (output .getvalue (), 'usage: ' )
32453241
32463242    def  test_exec_mode_flag (self ):
32473243        # test 'python -m ast -m/--mode exec' 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments