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


Python CommandTester.set_inputs方法代码示例

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


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

示例1: test_interactive_with_dependencies

# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import set_inputs [as 别名]
def test_interactive_with_dependencies(app, repo, mocker, poetry):
    repo.add_package(get_package("pendulum", "2.0.0"))
    repo.add_package(get_package("pytest", "3.6.0"))

    command = app.find("init")
    command._pool = poetry.pool

    mocker.patch("poetry.utils._compat.Path.open")
    p = mocker.patch("poetry.utils._compat.Path.cwd")
    p.return_value = Path(__file__).parent

    tester = CommandTester(command)
    tester.set_inputs(
        [
            "my-package",  # Package name
            "1.2.3",  # Version
            "This is a description",  # Description
            "n",  # Author
            "MIT",  # License
            "~2.7 || ^3.6",  # Python
            "",  # Interactive packages
            "pendulum",  # Search for package
            "0",  # First option
            "",  # Do not set constraint
            "",  # Stop searching for packages
            "",  # Interactive dev packages
            "pytest",  # Search for package
            "0",
            "",
            "",
            "\n",  # Generate
        ]
    )
    tester.execute([("command", command.name)])

    output = tester.get_display(True)
    expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "~2.7 || ^3.6"
pendulum = "^2.0"

[tool.poetry.dev-dependencies]
pytest = "^3.6"
"""

    assert expected in output
开发者ID:shawegit,项目名称:poetry,代码行数:55,代码来源:test_init.py

示例2: test_basic_interactive

# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import set_inputs [as 别名]
def test_basic_interactive(app, mocker, poetry):
    command = app.find("init")
    command._pool = poetry.pool

    mocker.patch("poetry.utils._compat.Path.open")
    p = mocker.patch("poetry.utils._compat.Path.cwd")
    p.return_value = Path(__file__)

    tester = CommandTester(command)
    tester.set_inputs(
        [
            "my-package",  # Package name
            "1.2.3",  # Version
            "This is a description",  # Description
            "n",  # Author
            "MIT",  # License
            "~2.7 || ^3.6",  # Python
            "n",  # Interactive packages
            "n",  # Interactive dev packages
            "\n",  # Generate
        ]
    )
    tester.execute([("command", command.name)])

    output = tester.get_display(True)
    expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <[email protected]>"]
license = "MIT"

[tool.poetry.dependencies]
python = "~2.7 || ^3.6"

[tool.poetry.dev-dependencies]
"""

    assert expected in output
开发者ID:shawegit,项目名称:poetry,代码行数:42,代码来源:test_init.py


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