File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1938,7 +1938,23 @@ def test_required_subparsers_no_destination_error(self):
1938
1938
parser = ErrorRaisingArgumentParser ()
1939
1939
subparsers = parser .add_subparsers ()
1940
1940
subparsers .add_parser ('run' )
1941
- self .assertArgumentParserError (parser .parse_args , ())
1941
+ with self .assertRaises (ArgumentParserError ) as excinfo :
1942
+ parser .parse_args (())
1943
+ self .assertRegex (
1944
+ excinfo .exception .stderr ,
1945
+ 'error: the following arguments are required: {run}\n $'
1946
+ )
1947
+
1948
+ def test_wrong_argument_subparsers_no_destination_error (self ):
1949
+ parser = ErrorRaisingArgumentParser ()
1950
+ subparsers = parser .add_subparsers ()
1951
+ subparsers .add_parser ('foo' )
1952
+ with self .assertRaises (ArgumentParserError ) as excinfo :
1953
+ parser .parse_args (('bar' ,))
1954
+ self .assertRegex (
1955
+ excinfo .exception .stderr ,
1956
+ r"error: argument {foo}: invalid choice: 'bar' \(choose from 'foo'\)\n$"
1957
+ )
1942
1958
1943
1959
def test_optional_subparsers (self ):
1944
1960
parser = ErrorRaisingArgumentParser ()
You can’t perform that action at this time.
0 commit comments