File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -1223,5 +1223,22 @@ def test_add_multiple_config_arguments_error(self):
12231223 parser .add_argument ('--cfg2' , action = ActionConfigFile )
12241224
12251225
1226+ def test_parser_alias (self ):
1227+ import jsonargparse
1228+
1229+ # Create a parser where --bar is an alias for --foo
1230+ parser = jsonargparse .ArgumentParser ()
1231+ parser .add_argument ('--foo' , '--bar' )
1232+
1233+ parsed = parser .parse_string ('foo: "aaa"' )
1234+ assert parsed .foo == 'aaa'
1235+
1236+ parsed = parser .parse_string ('bar: "bbb"' )
1237+ assert parsed .foo == 'bbb'
1238+
1239+ parsed = parser .parse_args (['--bar' , 'ccc' ])
1240+ assert parsed .foo == 'ccc'
1241+
1242+
12261243if __name__ == '__main__' :
12271244 unittest .main (verbosity = 2 )
You can’t perform that action at this time.
0 commit comments