JZ has proposed merging lp:~jzhuge/configglue/short_name_for_inischema_2 into lp:configglue.
Requested reviews: Configglue developers (configglue) For more details, see: https://code.launchpad.net/~jzhuge/configglue/short_name_for_inischema_2/+merge/308581 Support short_name attribute in config ini file for inischema. -- Your team Configglue developers is requested to review the proposed merge of lp:~jzhuge/configglue/short_name_for_inischema_2 into lp:configglue.
=== modified file 'configglue/inischema/glue.py' --- configglue/inischema/glue.py 2013-07-11 16:28:28 +0000 +++ configglue/inischema/glue.py 2016-10-16 04:17:04 +0000 @@ -83,6 +83,9 @@ parser_fun = lambda x: x attrs = {'name': option_name} + option_short_name = option.attrs.pop('short_name', None) + if option_short_name is not None: + attrs['short_name'] = option_short_name option_help = option.attrs.pop('help', None) if option_help is not None: attrs['help'] = option_help === modified file 'configglue/tests/inischema/test_glue.py' --- configglue/tests/inischema/test_glue.py 2013-07-11 16:28:28 +0000 +++ configglue/tests/inischema/test_glue.py 2016-10-16 04:17:04 +0000 @@ -123,6 +123,32 @@ self.assertEqual(options.x_a, '1') +class TestGlueShortName(TestBase): + ini = b'[x]\nlong_opt.short_name=L' + + def test_accepts_long_args(self): + parser, options, args = configglue(self.file, 'dummy', + args=['', '--x_long_opt=13579']) + self.assertEqual(options.x_long_opt, '13579') + + def test_accepts_short_args(self): + parser, options, args = configglue(self.file, 'dummy', + args=['', '-L86420']) + self.assertEqual(options.x_long_opt, '86420') + + def test_help_displays_both_args(self): + new_callable = StringIO + if PY2: + new_callable = BytesIO + + with patch('sys.stdout', new_callable=new_callable) as mock_stdout: + try: + configglue(self.file, args=['', '--help']) + except SystemExit: + output = mock_stdout.getvalue() + self.assertTrue('-L X_LONG_OPT, --x_long_opt=X_LONG_OPT' in output) + + class TestGlueBool(TestBase): ini = b'''[__main__] foo.parser=bool
_______________________________________________ Mailing list: https://launchpad.net/~configglue Post to : configglue@lists.launchpad.net Unsubscribe : https://launchpad.net/~configglue More help : https://help.launchpad.net/ListHelp