本文整理汇总了Python中cliff.app.App.options方法的典型用法代码示例。如果您正苦于以下问题:Python App.options方法的具体用法?Python App.options怎么用?Python App.options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cliff.app.App
的用法示例。
在下文中一共展示了App.options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_show_help_for_help
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import options [as 别名]
def test_show_help_for_help():
# FIXME(dhellmann): Are commands tied too closely to the app? Or
# do commands know too much about apps by using them to get to the
# command manager?
stdout = StringIO()
app = App('testing', '1',
utils.TestCommandManager(utils.TEST_NAMESPACE),
stdout=stdout)
app.NAME = 'test'
app.options = mock.Mock()
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')
parsed_args = parser.parse_args([])
try:
help_cmd.run(parsed_args)
except SystemExit:
pass
help_text = stdout.getvalue()
basecommand = os.path.split(sys.argv[0])[1]
assert 'usage: %s [--version]' % basecommand in help_text
assert 'optional arguments:\n --version' in help_text
expected = (
' one Test command.\n'
' three word command Test command.\n'
)
assert expected in help_text
示例2: test_show_help_print_exc_with_ep_load_fail
# 需要导入模块: from cliff.app import App [as 别名]
# 或者: from cliff.app.App import options [as 别名]
def test_show_help_print_exc_with_ep_load_fail(mock_load):
stdout = StringIO()
app = App('testing', '1',
utils.TestCommandManager(utils.TEST_NAMESPACE),
stdout=stdout)
app.NAME = 'test'
app.options = mock.Mock()
app.options.debug = True
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')
parsed_args = parser.parse_args([])
try:
help_cmd.run(parsed_args)
except SystemExit:
pass
help_output = stdout.getvalue()
assert 'Commands:' in help_output
assert 'Could not load' in help_output
assert 'Exception: Could not load EntryPoint' in help_output