From aca1805d911caefe14a73edb6ced281cf54e7ad2 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Fri, 26 Oct 2012 16:55:17 +0200 Subject: cfg: fix required if option has a dash If an option has a dash in it and is required, the check fails because it tries to self._get() on the name (with dash) rather than the dest (with underscore). Change-Id: I6448019f70f98bc2e58a325d0cf9ce88b8bb085b Signed-off-by: Julien Danjou --- tests/unit/test_cfg.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests') diff --git a/tests/unit/test_cfg.py b/tests/unit/test_cfg.py index e58f12c..b356fa5 100644 --- a/tests/unit/test_cfg.py +++ b/tests/unit/test_cfg.py @@ -1189,6 +1189,14 @@ class RequiredOptsTestCase(BaseTestCase): self.assertTrue(hasattr(self.conf, 'foo')) self.assertEquals(self.conf.foo, 'bar') + def test_required_cli_opt_with_dash(self): + self.conf.register_cli_opt(StrOpt('foo-bar', required=True)) + + self.conf(['--foo-bar', 'baz']) + + self.assertTrue(hasattr(self.conf, 'foo_bar')) + self.assertEquals(self.conf.foo_bar, 'baz') + def test_missing_required_opt(self): self.conf.register_opt(StrOpt('foo', required=True)) self.assertRaises(RequiredOptError, self.conf, []) -- cgit