diff --git a/jsonargparse_tests/test_alias.py b/jsonargparse_tests/test_alias.py deleted file mode 100644 index a4ddb144..00000000 --- a/jsonargparse_tests/test_alias.py +++ /dev/null @@ -1,10 +0,0 @@ -def test_alias(): - import jsonargparse - 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' diff --git a/jsonargparse_tests/test_core.py b/jsonargparse_tests/test_core.py index b76dfe14..e4c8fc61 100755 --- a/jsonargparse_tests/test_core.py +++ b/jsonargparse_tests/test_core.py @@ -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)