当前位置: 首页>>代码示例>>Python>>正文


Python Application.all方法代码示例

本文整理汇总了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")
开发者ID:onema,项目名称:cleo,代码行数:16,代码来源:test_application.py

示例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"
        )
开发者ID:onema,项目名称:cleo,代码行数:20,代码来源:test_application.py

示例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",
        )
开发者ID:onema,项目名称:cleo,代码行数:19,代码来源:test_application.py


注:本文中的cleo.application.Application.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。