@@ -2187,6 +2187,18 @@ def test_required_subparsers_no_destination_error(self):
21872187        )
21882188
21892189    def  test_wrong_argument_subparsers_no_destination_error (self ):
2190+         parser  =  ErrorRaisingArgumentParser ()
2191+         subparsers  =  parser .add_subparsers (required = True )
2192+         subparsers .add_parser ('foo' )
2193+         subparsers .add_parser ('bar' )
2194+         with  self .assertRaises (ArgumentParserError ) as  excinfo :
2195+             parser .parse_args (('test' ,))
2196+         self .assertRegex (
2197+             excinfo .exception .stderr ,
2198+             r"error: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$" 
2199+         )
2200+ 
2201+     def  test_wrong_argument_subparsers_no_destination_error_with_closest_choice_input (self ):
21902202        parser  =  ErrorRaisingArgumentParser ()
21912203        subparsers  =  parser .add_subparsers (required = True )
21922204        subparsers .add_parser ('foo' )
@@ -2195,7 +2207,7 @@ def test_wrong_argument_subparsers_no_destination_error(self):
21952207            parser .parse_args (('baz' ,))
21962208        self .assertRegex (
21972209            excinfo .exception .stderr ,
2198-             r"error: argument {foo,bar}: invalid choice: 'baz' \(choose from 'foo', 'bar'\)\n$" ,
2210+             r"error: argument {foo,bar}: invalid choice: 'baz', maybe you meant bar?  \(choose from 'foo', 'bar'\)\n$" ,
21992211        )
22002212
22012213    def  test_optional_subparsers (self ):
0 commit comments