summaryrefslogtreecommitdiff
path: root/tests/test_cfg.py
diff options
context:
space:
mode:
authorDavanum Srinivas <dims@linux.vnet.ibm.com>2013-07-02 12:16:38 -0400
committerDavanum Srinivas <dims@linux.vnet.ibm.com>2013-07-11 07:53:26 -0400
commit3302fb05723e62f9b02c2cce74e30ded1edfda51 (patch)
tree9a13730da149613f106b45b9995737dcc795d93a /tests/test_cfg.py
parent29bf15d65d54219cd76a7f2b18bab0272bc180fe (diff)
downloadoslo-config-3302fb05723e62f9b02c2cce74e30ded1edfda51.tar.gz
Raise an exception when _oparser is not initialized
Throw an exception when print_help and print_usage are called before __call__() is invoked on ConfigOpts object Fixes LP# 1196601 Change-Id: I2c3b412c5aa9adef87a92103b9749cc66158a3e4
Diffstat (limited to 'tests/test_cfg.py')
-rw-r--r--tests/test_cfg.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_cfg.py b/tests/test_cfg.py
index 698012a..b75f4bc 100644
--- a/tests/test_cfg.py
+++ b/tests/test_cfg.py
@@ -2831,3 +2831,20 @@ class ChoicesTestCase(BaseTestCase):
self.assertTrue(hasattr(self.conf, 'foo'))
self.assertEqual(self.conf.foo, 'baaar')
+
+
+class PrintHelpTestCase(utils.BaseTestCase):
+
+ def test_print_help_without_init(self):
+ conf = cfg.ConfigOpts()
+ conf.register_opts([])
+ self.assertRaises(cfg.NotInitializedError,
+ conf.print_help)
+
+ def test_print_help_with_clear(self):
+ conf = cfg.ConfigOpts()
+ conf.register_opts([])
+ conf([])
+ conf.clear()
+ self.assertRaises(cfg.NotInitializedError,
+ conf.print_help)