diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-09-14 08:02:07 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-09-15 07:01:13 +0200 |
commit | ef7ca4a4d7a71a470182f5e88a2a3398853daa9f (patch) | |
tree | a97f93774d57d890e1a1b7dfd56546a0d64496ae /tests/18_test_Config.py | |
parent | 3b94d2373c49bd3a63fe27ecf6dbf4bee7b8c567 (diff) |
config: allow to set short options
Diffstat (limited to 'tests/18_test_Config.py')
-rw-r--r-- | tests/18_test_Config.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/18_test_Config.py b/tests/18_test_Config.py index 306999f3..54c00bec 100644 --- a/tests/18_test_Config.py +++ b/tests/18_test_Config.py @@ -109,3 +109,25 @@ class TestConfigParser(unittest.TestCase, GbpLogTester): self.assertTrue('upstream-branch' in params) self.assertTrue('debian-branch' in params) self.assertTrue('color' in params) + + def test_short_option_with_prefix(self): + """Options with short options can't have a prefix""" + class TestOptonParser(GbpOptionParser): + list_opts = [] + defaults = {'withshort': 'foo'} + short_opts = {'withshort': '-S'} + parser = TestOptonParser('cmd', prefix='p') + with self.assertRaisesRegexp(ValueError, "Options with prefix cannot have a short option"): + parser.add_config_file_option(option_name="withshort", dest="with_short", help="foo") + + def test_short_option(self): + class TestOptionParser(GbpOptionParser): + list_opts = [] + defaults = {'withshort': 'foo'} + short_opts = {'withshort': '-S'} + + parser = TestOptionParser('cmd') + parser.add_config_file_option(option_name="withshort", dest="with_short", help="foo") + self.assertItemsEqual(['withshort'], parser.valid_options) + self.assertTrue(parser.has_option("--withshort")) + self.assertTrue(parser.has_option("-S")) |