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


Python testers.CommandTester类代码示例

本文整理汇总了Python中cleo.testers.CommandTester的典型用法代码示例。如果您正苦于以下问题:Python CommandTester类的具体用法?Python CommandTester怎么用?Python CommandTester使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandTester类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_explicit_multiple_argument

def test_explicit_multiple_argument():
    command = MySecondCommand()

    tester = CommandTester(command)
    tester.execute("1 2 3")

    assert "1,2,3\n" == tester.io.fetch_output()
开发者ID:sdispater,项目名称:cleo,代码行数:7,代码来源:test_command.py

示例2: test_add_constraint

def test_add_constraint(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

    repo.add_package(get_package("cachy", "0.1.0"))
    repo.add_package(get_package("cachy", "0.2.0"))

    tester.execute([("command", command.get_name()), ("name", ["cachy=0.1.0"])])

    expected = """\

Updating dependencies
Resolving dependencies...


Package operations: 1 install, 0 updates, 0 removals

Writing lock file

  - Installing cachy (0.1.0)
"""

    assert tester.get_display(True) == expected

    assert len(installer.installs) == 1
开发者ID:singulared,项目名称:poetry,代码行数:25,代码来源:test_add.py

示例3: test_add_git_constraint_with_poetry

def test_add_git_constraint_with_poetry(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

    repo.add_package(get_package("pendulum", "1.4.4"))

    tester.execute(
        [
            ("command", command.get_name()),
            ("name", ["demo"]),
            ("--git", "https://github.com/demo/pyproject-demo.git"),
        ]
    )

    expected = """\

Updating dependencies
Resolving dependencies...


Package operations: 2 installs, 0 updates, 0 removals

Writing lock file

  - Installing pendulum (1.4.4)
  - Installing demo (0.1.2 9cf87a2)
"""

    assert tester.get_display(True) == expected

    assert len(installer.installs) == 2
开发者ID:singulared,项目名称:poetry,代码行数:31,代码来源:test_add.py

示例4: test_add_constraint_dependencies

def test_add_constraint_dependencies(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

    cachy2 = get_package("cachy", "0.2.0")
    msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6")
    cachy2.requires = [msgpack_dep]

    repo.add_package(get_package("cachy", "0.1.0"))
    repo.add_package(cachy2)
    repo.add_package(get_package("msgpack-python", "0.5.3"))

    tester.execute([("command", command.get_name()), ("name", ["cachy=0.2.0"])])

    expected = """\

Updating dependencies
Resolving dependencies...


Package operations: 2 installs, 0 updates, 0 removals

Writing lock file

  - Installing msgpack-python (0.5.3)
  - Installing cachy (0.2.0)
"""

    assert tester.get_display(True) == expected

    assert len(installer.installs) == 2
开发者ID:singulared,项目名称:poetry,代码行数:31,代码来源:test_add.py

示例5: test_add_no_constraint

def test_add_no_constraint(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

    repo.add_package(get_package("cachy", "0.1.0"))
    repo.add_package(get_package("cachy", "0.2.0"))

    tester.execute([("command", command.get_name()), ("name", ["cachy"])])

    expected = """\
Using version ^0.2.0 for cachy

Updating dependencies
Resolving dependencies...


Package operations: 1 install, 0 updates, 0 removals

Writing lock file

  - Installing cachy (0.2.0)
"""

    assert tester.get_display(True) == expected

    assert len(installer.installs) == 1

    content = app.poetry.file.read()["tool"]["poetry"]

    assert "cachy" in content["dependencies"]
    assert content["dependencies"]["cachy"] == "^0.2.0"
开发者ID:singulared,项目名称:poetry,代码行数:31,代码来源:test_add.py

示例6: test_show_outdated

def test_show_outdated(app, poetry, installed, repo):
    command = app.find("show")
    tester = CommandTester(command)

    cachy_010 = get_package("cachy", "0.1.0")
    cachy_010.description = "Cachy package"
    cachy_020 = get_package("cachy", "0.2.0")
    cachy_020.description = "Cachy package"

    pendulum_200 = get_package("pendulum", "2.0.0")
    pendulum_200.description = "Pendulum package"

    installed.add_package(cachy_010)
    installed.add_package(pendulum_200)

    repo.add_package(cachy_010)
    repo.add_package(cachy_020)
    repo.add_package(pendulum_200)

    poetry.locker.mock_lock_data(
        {
            "package": [
                {
                    "name": "cachy",
                    "version": "0.1.0",
                    "description": "Cachy package",
                    "category": "main",
                    "optional": False,
                    "platform": "*",
                    "python-versions": "*",
                    "checksum": [],
                },
                {
                    "name": "pendulum",
                    "version": "2.0.0",
                    "description": "Pendulum package",
                    "category": "main",
                    "optional": False,
                    "platform": "*",
                    "python-versions": "*",
                    "checksum": [],
                },
            ],
            "metadata": {
                "python-versions": "*",
                "platform": "*",
                "content-hash": "123456789",
                "hashes": {"cachy": [], "pendulum": []},
            },
        }
    )

    tester.execute([("command", command.get_name()), ("--outdated", True)])

    expected = """\
cachy    0.1.0 0.2.0 Cachy package
"""

    assert tester.get_display(True) == expected
开发者ID:shawegit,项目名称:poetry,代码行数:59,代码来源:test_show.py

示例7: test_execute_for_application_command

 def test_execute_for_application_command(self):
     application = Application()
     tester = CommandTester(application.get('help'))
     tester.execute([('command_name', 'list')])
     self.assertRegex(
         tester.get_display(),
         'list \[--raw\] \[namespace\]'
     )
开发者ID:hason,项目名称:cleo,代码行数:8,代码来源:test_help_command.py

示例8: test_overwrite

def test_overwrite():
    command = MyCommand()

    tester = CommandTester(command)
    tester.execute("overwrite", decorated=True)

    expected = "Processing...{}Done!        {}".format("\x08" * 13, "\x08" * 8)
    assert expected == tester.io.fetch_output()
开发者ID:sdispater,项目名称:cleo,代码行数:8,代码来源:test_command.py

示例9: test_execute_for_command

 def test_execute_for_command(self):
     command = HelpCommand()
     tester = CommandTester(command)
     command.set_command(ListCommand())
     tester.execute([])
     self.assertRegex(
         tester.get_display(),
         'list \[--raw\] \[namespace\]'
     )
开发者ID:hason,项目名称:cleo,代码行数:9,代码来源:test_help_command.py

示例10: test_execute_for_command_alias

 def test_execute_for_command_alias(self):
     command = HelpCommand()
     command.set_application(Application())
     tester = CommandTester(command)
     tester.execute([('command_name', 'li')])
     self.assertRegex(
         tester.get_display(),
         'list \[--raw\] \[namespace\]'
     )
开发者ID:hason,项目名称:cleo,代码行数:9,代码来源:test_help_command.py

示例11: test_run_non_interactive

    def test_run_non_interactive(self):
        tester = CommandTester(TestCommand())

        tester.execute([], {'interactive': False})

        self.assertEqual(
            'execute called\n',
            tester.get_display()
        )
开发者ID:onema,项目名称:cleo,代码行数:9,代码来源:test_command.py

示例12: test_as_text

    def test_as_text(self):
        command = TestCommand()
        command.set_application(Application())
        tester = CommandTester(command)
        tester.execute([('command', command.get_name())])

        self.assertEqual(
            self.open_fixture('command_astext.txt'),
            command.as_text()
        )
开发者ID:onema,项目名称:cleo,代码行数:10,代码来源:test_command.py

示例13: test_about

def test_about(app):
    command = app.find("check")
    tester = CommandTester(command)

    tester.execute([("command", command.get_name())])

    expected = """\
All set!
"""

    assert tester.get_display(True) == expected
开发者ID:shawegit,项目名称:poetry,代码行数:11,代码来源:test_check.py

示例14: test_show_basic_with_not_installed_packages_decorated

def test_show_basic_with_not_installed_packages_decorated(app, poetry, installed):
    command = app.find("show")
    tester = CommandTester(command)

    cachy_010 = get_package("cachy", "0.1.0")
    cachy_010.description = "Cachy package"

    pendulum_200 = get_package("pendulum", "2.0.0")
    pendulum_200.description = "Pendulum package"

    installed.add_package(cachy_010)
    poetry.locker.mock_lock_data(
        {
            "package": [
                {
                    "name": "cachy",
                    "version": "0.1.0",
                    "description": "Cachy package",
                    "category": "main",
                    "optional": False,
                    "platform": "*",
                    "python-versions": "*",
                    "checksum": [],
                },
                {
                    "name": "pendulum",
                    "version": "2.0.0",
                    "description": "Pendulum package",
                    "category": "main",
                    "optional": False,
                    "platform": "*",
                    "python-versions": "*",
                    "checksum": [],
                },
            ],
            "metadata": {
                "python-versions": "*",
                "platform": "*",
                "content-hash": "123456789",
                "hashes": {"cachy": [], "pendulum": []},
            },
        }
    )

    tester.execute([("command", command.get_name())], {"decorated": True})

    expected = """\
\033[32mcachy   \033[0m \033[36m0.1.0\033[0m Cachy package
\033[31mpendulum\033[0m \033[36m2.0.0\033[0m Pendulum package
"""

    assert tester.get_display(True) == expected
开发者ID:shawegit,项目名称:poetry,代码行数:52,代码来源:test_show.py

示例15: test_display_single_setting

def test_display_single_setting(app, config):
    command = app.find("config")
    command._config = Config(config.file)
    tester = CommandTester(command)

    tester.execute(
        [("command", command.get_name()), ("key", "settings.virtualenvs.create")]
    )

    expected = """true
"""

    assert tester.get_display(True) == expected
开发者ID:singulared,项目名称:poetry,代码行数:13,代码来源:test_config.py


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