Skip to content

Commit

Permalink
Move alias test to core
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Apr 24, 2023
1 parent f835e94 commit af8b185
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
10 changes: 0 additions & 10 deletions jsonargparse_tests/test_alias.py

This file was deleted.

17 changes: 17 additions & 0 deletions jsonargparse_tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,5 +1223,22 @@ def test_add_multiple_config_arguments_error(self):
parser.add_argument('--cfg2', action=ActionConfigFile)


def test_parser_alias(self):
import jsonargparse

# Create a parser where --bar is an alias for --foo
parser = jsonargparse.ArgumentParser()
parser.add_argument('--foo', '--bar')

parsed = parser.parse_string('foo: "aaa"')
assert parsed.foo == 'aaa'

parsed = parser.parse_string('bar: "bbb"')
assert parsed.foo == 'bbb'

parsed = parser.parse_args(['--bar', 'ccc'])
assert parsed.foo == 'ccc'


if __name__ == '__main__':
unittest.main(verbosity=2)

0 comments on commit af8b185

Please sign in to comment.