本文整理汇总了Python中cleo.application.Application.all方法的典型用法代码示例。如果您正苦于以下问题:Python Application.all方法的具体用法?Python Application.all怎么用?Python Application.all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cleo.application.Application
的用法示例。
在下文中一共展示了Application.all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_all
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import all [as 别名]
def test_all(self):
"""
Application.get_all() returns all comands of the application
"""
application = Application()
commands = application.all()
self.assertEqual(
"HelpCommand", commands["help"].__class__.__name__, msg=".all() returns the registered commands"
)
application.add(FooCommand())
self.assertEqual(1, len(application.all("foo")), msg=".all() take a namespace as first argument")
示例2: test_add
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import all [as 别名]
def test_add(self):
"""
Application.add() and .addCommands() register commands
"""
application = Application()
foo = FooCommand()
application.add(foo)
self.assertEqual(foo, application.all()["foo:bar"], msg=".add() registers a command")
application = Application()
foo, foo1 = FooCommand(), Foo1Command()
application.add_commands([foo, foo1])
commands = application.all()
self.assertEqual(
[foo, foo1], [commands["foo:bar"], commands["foo:bar1"]], msg=".add_commands() registers a list of commands"
)
示例3: test_constructor
# 需要导入模块: from cleo.application import Application [as 别名]
# 或者: from cleo.application.Application import all [as 别名]
def test_constructor(self):
"""
Application.__init__() behaves properly
"""
application = Application("foo", "bar")
self.assertEqual(
"foo", application.get_name(), msg="__init__() takes the application name as its first argument"
)
self.assertEqual(
"bar", application.get_version(), msg="__init__() takes the application version as its second argument"
)
self.assertEqual(
["help", "list"].sort(),
list(application.all().keys()).sort(),
msg="__init__() registered the help and list commands by default",
)