本文整理汇总了Python中cleo.testers.CommandTester.get_display方法的典型用法代码示例。如果您正苦于以下问题:Python CommandTester.get_display方法的具体用法?Python CommandTester.get_display怎么用?Python CommandTester.get_display使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cleo.testers.CommandTester
的用法示例。
在下文中一共展示了CommandTester.get_display方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_git_constraint_with_poetry
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例2: test_add_constraint_dependencies
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例3: test_add_no_constraint
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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"
示例4: test_add_constraint
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例5: test_show_outdated
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例6: test_execute_for_application_command
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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\]'
)
示例7: test_run_non_interactive
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
def test_run_non_interactive(self):
tester = CommandTester(TestCommand())
tester.execute([], {'interactive': False})
self.assertEqual(
'execute called\n',
tester.get_display()
)
示例8: test_execute_for_command
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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\]'
)
示例9: test_execute_for_command_alias
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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\]'
)
示例10: test_about
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例11: test_set_code
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
def test_set_code(self):
command = TestCommand()
ret = command.set_code(lambda in_, out_: out_.writeln('from the code...'))
self.assertEqual(ret, command)
tester = CommandTester(command)
tester.execute([])
self.assertEqual(
'interact called\nfrom the code...\n',
tester.get_display()
)
command = TestCommand()
command.set_code(self.callable_method)
tester = CommandTester(command)
tester.execute([])
self.assertEqual(
'interact called\nfrom the code...\n',
tester.get_display()
)
示例12: test_interactive_with_dependencies
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [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
示例13: test_show_basic_with_not_installed_packages_decorated
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例14: test_display_single_setting
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
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
示例15: test_list_displays_default_value_if_not_set
# 需要导入模块: from cleo.testers import CommandTester [as 别名]
# 或者: from cleo.testers.CommandTester import get_display [as 别名]
def test_list_displays_default_value_if_not_set(app, config):
command = app.find("config")
command._config = Config(config.file)
tester = CommandTester(command)
tester.execute([("command", command.get_name()), ("--list", True)])
expected = """settings.virtualenvs.create = true
settings.virtualenvs.in-project = false
settings.virtualenvs.path = "."
repositories = {}
"""
assert tester.get_display(True) == expected