Skip to content

Commit af8b185

Browse files
committed
Move alias test to core
1 parent f835e94 commit af8b185

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

jsonargparse_tests/test_alias.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

jsonargparse_tests/test_core.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
12261243
if __name__ == '__main__':
12271244
unittest.main(verbosity=2)

0 commit comments

Comments
 (0)