當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。