本文整理汇总了Python中cleo.application.Application.get_definition方法的典型用法代码示例。如果您正苦于以下问题:Python Application.get_definition方法的具体用法?Python Application.get_definition怎么用?Python Application.get_definition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cleo.application.Application
的用法示例。
在下文中一共展示了Application.get_definition方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merge_application_definition
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import get_definition [as 别名]
def test_merge_application_definition(self):
"""
Command.merge_application_definition() merges command and application.
"""
application1 = Application()
application1.get_definition().add_arguments([InputArgument('foo')])
application1.get_definition().add_options([InputOption('bar')])
command = TestCommand()
command.set_application(application1)
command.set_definition(
InputDefinition([
InputArgument('bar'),
InputOption('foo')
])
)
command.merge_application_definition()
self.assertTrue(command.get_definition().has_argument('foo'))
self.assertTrue(command.get_definition().has_option('foo'))
self.assertTrue(command.get_definition().has_argument('bar'))
self.assertTrue(command.get_definition().has_option('bar'))
# It should not merge the definitions twice
command.merge_application_definition()
self.assertEqual(3, command.get_definition().get_argument_count())
示例2: test_merge_application_definition_without_args_then_with_args_adds_args
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import get_definition [as 别名]
def test_merge_application_definition_without_args_then_with_args_adds_args(self):
application1 = Application()
application1.get_definition().add_arguments([InputArgument('foo')])
application1.get_definition().add_options([InputOption('bar')])
command = TestCommand()
command.set_application(application1)
command.set_definition(InputDefinition())
command.merge_application_definition(False)
self.assertFalse(command.get_definition().has_argument('foo'))
self.assertTrue(command.get_definition().has_option('bar'))
command.merge_application_definition(True)
self.assertTrue(command.get_definition().has_argument('foo'))
# It should not merge the definitions twice
command.merge_application_definition()
self.assertEqual(2, command.get_definition().get_argument_count())
示例3: test_get_default_input_definition_returns_default_values
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import get_definition [as 别名]
def test_get_default_input_definition_returns_default_values(self):
application = Application()
application.set_auto_exit(False)
application.set_catch_exceptions(False)
definition = application.get_definition()
self.assertTrue(definition.has_argument("command"))
self.assertTrue(definition.has_option("help"))
self.assertTrue(definition.has_option("quiet"))
self.assertTrue(definition.has_option("verbose"))
self.assertTrue(definition.has_option("version"))
self.assertTrue(definition.has_option("ansi"))
self.assertTrue(definition.has_option("no-ansi"))
self.assertTrue(definition.has_option("no-interaction"))
示例4: test_setting_input_definition_overwrites_default_values
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import get_definition [as 别名]
def test_setting_input_definition_overwrites_default_values(self):
application = Application()
application.set_auto_exit(False)
application.set_catch_exceptions(False)
application.set_definition(
InputDefinition([InputOption("--custom", "-c", InputOption.VALUE_NONE, "Set the custom input definition.")])
)
definition = application.get_definition()
self.assertFalse(definition.has_argument("command"))
self.assertFalse(definition.has_option("help"))
self.assertFalse(definition.has_option("quiet"))
self.assertFalse(definition.has_option("verbose"))
self.assertFalse(definition.has_option("version"))
self.assertFalse(definition.has_option("ansi"))
self.assertFalse(definition.has_option("no-ansi"))
self.assertFalse(definition.has_option("no-interaction"))
self.assertTrue(definition.has_option("custom"))