From 614082e6a6ba025583ce24a2cce94133997925d7 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Thu, 13 Dec 2012 09:23:32 -0500 Subject: Add tests for the help command & --help options Move the parser setup from bootstrap_with_global_options to bootstrap, so all API objects have access to it. Add some CLI tests for the help system. Part of the effort for https://fedorahosted.org/freeipa/ticket/3060 --- ipalib/plugable.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'ipalib/plugable.py') diff --git a/ipalib/plugable.py b/ipalib/plugable.py index 8f42c630..fe09d3a6 100644 --- a/ipalib/plugable.py +++ b/ipalib/plugable.py @@ -456,7 +456,7 @@ class API(DictProxy): def isdone(self, name): return name in self.__done - def bootstrap(self, **overrides): + def bootstrap(self, parser=None, **overrides): """ Initialize environment variables and logging. """ @@ -516,6 +516,10 @@ class API(DictProxy): log.error('Cannot open log file %r: %s', self.env.log, e) return + if not parser: + parser = self.build_global_parser() + object.__setattr__(self, 'parser', parser) + def build_global_parser(self, parser=None, context=None): """ Add global options to an optparse.OptionParser instance. @@ -592,8 +596,7 @@ class API(DictProxy): overrides['webui_prod'] = options.prod if context is not None: overrides['context'] = context - self.bootstrap(**overrides) - object.__setattr__(self, 'parser', parser) + self.bootstrap(parser, **overrides) return (options, args) def load_plugins(self): -- cgit