diff options
author | Julien Danjou <julien@danjou.info> | 2012-10-26 16:55:17 +0200 |
---|---|---|
committer | Julien Danjou <julien@danjou.info> | 2012-10-26 16:55:17 +0200 |
commit | aca1805d911caefe14a73edb6ced281cf54e7ad2 (patch) | |
tree | 6ccec48bc1aa2ff4444ff25e1c24040f48a0d7d5 /tests | |
parent | d887090b5a31672e4a12f302b3818e2b0933bef0 (diff) | |
download | oslo-aca1805d911caefe14a73edb6ced281cf54e7ad2.tar.gz oslo-aca1805d911caefe14a73edb6ced281cf54e7ad2.tar.xz oslo-aca1805d911caefe14a73edb6ced281cf54e7ad2.zip |
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 <julien@danjou.info>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_cfg.py | 8 |
1 files changed, 8 insertions, 0 deletions
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, []) |