示例#1
0
def tester(app, poetry, config, executor, env):
    tester = CommandTester(app.find("add"))

    executor._io = tester.io

    installer = Installer(
        tester.io,
        env,
        poetry.package,
        poetry.locker,
        poetry.pool,
        config,
        executor=executor,
    )
    installer.use_executor(True)
    tester._command.set_installer(installer)
    tester._command.set_env(env)

    return tester
示例#2
0
def test_debug_resolve_git_dependency(app, repo):
    repo.add_package(get_package("pendulum", "2.0.3"))
    repo.add_package(get_package("cleo", "0.6.5"))

    command = app.find("debug resolve")
    tester = CommandTester(command)

    tester.execute("git+https://github.com/demo/demo.git")

    expected = """\
Resolving dependencies...

Resolution results:

pendulum 2.0.3
demo     0.1.2
"""

    assert expected == tester.io.fetch_output()
示例#3
0
def test_add_git_constraint_with_poetry_bad_name(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

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

    with pytest.raises(RuntimeError) as e:
        tester.execute(
            [
                ("command", command.get_name()),
                ("name", ["demox"]),
                ("--git", "https://github.com/demo/pyproject-demo.git"),
            ]
        )
    expected = (
        "The dependency name for demox does not match the actual package's name: demo"
    )
    assert str(e.value) == expected
    assert len(installer.installs) == 0
示例#4
0
def test_list_displays_set_get_local_setting(app, config):
    command = app.find("config")
    tester = CommandTester(command)

    tester.execute("virtualenvs.create false --local")

    tester.execute("--list")

    expected = """cache-dir = "/foo"
experimental.new-installer = true
virtualenvs.create = false
virtualenvs.in-project = false
virtualenvs.path = {path}  # /foo{sep}virtualenvs
""".format(
        path=json.dumps(os.path.join("{cache-dir}", "virtualenvs")), sep=os.path.sep
    )

    assert 1 == config.set_config_source.call_count
    assert expected == tester.io.fetch_output()
示例#5
0
    def test_detect_opts_3(self):
        table = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
        dialect = SimpleDialect(delimiter=";", quotechar="", escapechar="")
        tmpfname = self._build_file(table, dialect)

        application = build_application()
        command = application.find("detect")
        tester = CommandTester(command)
        tester.execute(f"--plain {tmpfname}")

        exp = """\
delimiter = ;
quotechar =
escapechar ="""
        try:
            output = tester.io.fetch_output().strip()
            self.assertEqual(exp, output)
        finally:
            os.unlink(tmpfname)
示例#6
0
def test_add_constraint_with_extras(app, repo, installer):
    command = app.find('add')
    tester = CommandTester(command)

    cachy2 = get_package('cachy', '0.2.0')
    cachy2.extras = {'msgpack': [get_dependency('msgpack-python')]}
    msgpack_dep = get_dependency('msgpack-python', '>=0.5 <0.6', optional=True)
    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']),
                    ('--extras', ['msgpack'])])

    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() == expected

    assert len(installer.installs) == 2

    content = app.poetry.file.read(raw=True)['tool']['poetry']

    assert 'cachy' in content['dependencies']
    assert content['dependencies']['cachy'] == {
        'version': '0.2.0',
        'extras': ['msgpack']
    }
示例#7
0
文件: test_add.py 项目: zhyr/poetry
def test_add_constraint_with_platform(app, repo, installer):
    platform = sys.platform
    command = app.find("add")
    tester = CommandTester(command)

    cachy2 = get_package("cachy", "0.2.0")

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

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

    expected = """\

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"] == {
        "version": "0.2.0",
        "platform": platform,
    }
示例#8
0
def test_none_activated(app, tmp_dir, config):
    app.poetry._config = config

    config.add_property("settings.virtualenvs.path", str(tmp_dir))

    venv_name = EnvManager.generate_env_name("simple_project",
                                             str(app.poetry.file.parent))
    (Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
    (Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()

    command = app.find("env list")
    tester = CommandTester(command)
    tester.execute()

    expected = """\
{}-py3.6
{}-py3.7
""".format(venv_name, venv_name)

    assert expected == tester.io.fetch_output()
示例#9
0
def test_none_activated(app, tmp_dir, mocker, env):
    mocker.patch("poetry.utils.env.EnvManager.get", return_value=env)

    app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})

    venv_name = EnvManager.generate_env_name("simple-project",
                                             str(app.poetry.file.parent))
    (Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
    (Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()

    command = app.find("env list")
    tester = CommandTester(command)
    tester.execute()

    expected = """\
{}-py3.6
{}-py3.7
""".format(venv_name, venv_name)

    assert expected == tester.io.fetch_output()
示例#10
0
def test_remove_by_name(app, tmp_dir, config, mocker):
    app.poetry._config = config

    config.add_property("settings.virtualenvs.path", str(tmp_dir))

    venv_name = EnvManager.generate_env_name("simple_project",
                                             str(app.poetry.file.parent))
    (Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
    (Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()

    command = app.find("env remove")
    tester = CommandTester(command)
    tester.execute("{}-py3.6".format(venv_name))

    assert not (Path(tmp_dir) / "{}-py3.6".format(venv_name)).exists()

    expected = "Deleted virtualenv: {}\n".format(
        (Path(tmp_dir) / "{}-py3.6".format(venv_name)))

    assert expected == tester.io.fetch_output()
示例#11
0
    def test_standardize_1(self):
        table = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
        dialect = SimpleDialect(delimiter=";", quotechar="", escapechar="")
        tmpfname = self._build_file(table, dialect)

        application = build_application()
        command = application.find("standardize")
        tester = CommandTester(command)
        tester.execute(tmpfname)

        # Excel format (i.e. RFC4180) *requires* CRLF
        crlf = "\r\n"
        exp = crlf.join(["A,B,C", "1,2,3", "4,5,6"])
        # add line terminator of last row
        exp += crlf
        try:
            output = tester.io.fetch_output()
            self.assertEqual(exp, output)
        finally:
            os.unlink(tmpfname)
示例#12
0
    def test_standardize_in_place_multi_noop(self):
        table = [["Å", "B", "C"], [1, 2, 3], [4, 5, 6]]
        dialects = ["excel", "excel", "excel"]
        tmpfnames = [self._build_file(table, D, newline="") for D in dialects]

        application = build_application()
        command = application.find("standardize")
        tester = CommandTester(command)
        retcode = tester.execute(f"-i {' '.join(tmpfnames)}")

        self.assertEqual(retcode, 0)

        exp = "\r\n".join([",".join(map(str, row)) for row in table]) + "\r\n"
        try:
            for tmpfname in tmpfnames:
                with open(tmpfname, "r", newline="") as fp:
                    contents = fp.read()
                self.assertEqual(contents, exp)
        finally:
            any(map(os.unlink, tmpfnames))
示例#13
0
    def test_standardize_3(self):
        table = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
        dialect = SimpleDialect(delimiter=";", quotechar="", escapechar="")
        tmpfname = self._build_file(table, dialect)

        tmpfd, tmpoutname = tempfile.mkstemp(suffix=".csv")
        os.close(tmpfd)

        application = build_application()
        command = application.find("standardize")
        tester = CommandTester(command)
        tester.execute(f"-t {tmpfname}")

        exp = "A,1,4\nB,2,5\nC,3,6"

        try:
            output = tester.io.fetch_output().strip()
            self.assertEqual(exp, output)
        finally:
            os.unlink(tmpfname)
示例#14
0
def test_get_prefers_explicitly_activated_virtualenvs_over_env_var(
    app, tmp_dir, mocker
):
    mocker.stopall()
    os.environ["VIRTUAL_ENV"] = "/environment/prefix"

    venv_name = EnvManager.generate_env_name(
        "simple-project", str(app.poetry.file.parent)
    )
    current_python = sys.version_info[:3]
    python_minor = ".".join(str(v) for v in current_python[:2])
    python_patch = ".".join(str(v) for v in current_python)

    app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})
    (Path(tmp_dir) / "{}-py{}".format(venv_name, python_minor)).mkdir()

    envs_file = TomlFile(Path(tmp_dir) / "envs.toml")
    doc = tomlkit.document()
    doc[venv_name] = {"minor": python_minor, "patch": python_patch}
    envs_file.write(doc)

    mocker.patch(
        "poetry.utils._compat.subprocess.check_output",
        side_effect=check_output_wrapper(Version(*current_python)),
    )
    mocker.patch(
        "poetry.utils._compat.subprocess.Popen.communicate",
        side_effect=[("/prefix", None), ("/prefix", None), ("/prefix", None)],
    )

    command = app.find("env use")
    tester = CommandTester(command)
    tester.execute(python_minor)

    expected = """\
Using virtualenv: {}
""".format(
        os.path.join(tmp_dir, "{}-py{}".format(venv_name, python_minor))
    )

    assert expected == tester.io.fetch_output()
示例#15
0
def test_predefined_dev_dependency(app, repo, mocker, poetry):
    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__)

    tester = CommandTester(command)
    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("--dev-dependency pytest", inputs="\n".join(inputs))

    expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <*****@*****.**>"]
license = "MIT"

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

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

    assert expected in tester.io.fetch_output()
示例#16
0
def test_list_displays_set_get_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"),
        ("value", ["false"]),
    ])

    command._config = Config(config.file)
    tester.execute([("command", command.get_name()), ("--list", True)])

    expected = """settings.virtualenvs.create = false
settings.virtualenvs.in-project = false
settings.virtualenvs.path = "."
repositories = {}
"""

    assert tester.get_display(True) == expected
示例#17
0
def test_add_url_constraint_wheel_with_extras(app, repo, installer, mocker):
    command = app.find("add")
    tester = CommandTester(command)

    repo.add_package(get_package("pendulum", "1.4.4"))
    repo.add_package(get_package("cleo", "0.6.5"))
    repo.add_package(get_package("tomlkit", "0.5.5"))

    tester.execute(
        "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl[foo,bar]"
    )

    expected = """\

Updating dependencies
Resolving dependencies...

Writing lock file


Package operations: 4 installs, 0 updates, 0 removals

  - Installing cleo (0.6.5)
  - Installing pendulum (1.4.4)
  - Installing tomlkit (0.5.5)
  - Installing demo (0.1.0 https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl)
"""

    assert expected == tester.io.fetch_output()

    assert len(installer.installs) == 4

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

    assert "demo" in content["dependencies"]
    assert content["dependencies"]["demo"] == {
        "url":
        "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl",
        "extras": ["foo", "bar"],
    }
示例#18
0
def test_add_constraint_with_extras_option(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

    cachy2 = get_package("cachy", "0.2.0")
    cachy2.extras = {"msgpack": [get_dependency("msgpack-python")]}
    msgpack_dep = get_dependency("msgpack-python", ">=0.5 <0.6", optional=True)
    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("cachy=0.2.0 --extras msgpack")

    expected = """\

Updating dependencies
Resolving dependencies...

Writing lock file


Package operations: 2 installs, 0 updates, 0 removals

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

    assert expected == tester.io.fetch_output()

    assert len(installer.installs) == 2

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

    assert "cachy" in content["dependencies"]
    assert content["dependencies"]["cachy"] == {
        "version": "0.2.0",
        "extras": ["msgpack"],
    }
示例#19
0
文件: test_add.py 项目: zhyr/poetry
def test_add_git_constraint(app, repo, installer):
    command = app.find("add")
    tester = CommandTester(command)

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

    tester.execute(
        [
            ("command", command.get_name()),
            ("name", ["demo"]),
            ("--git", "https://github.com/demo/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

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

    assert "demo" in content["dependencies"]
    assert content["dependencies"]["demo"] == {
        "git": "https://github.com/demo/demo.git"
    }
示例#20
0
def test_show_outdated_with_only_up_to_date_packages(app, poetry, installed,
                                                     repo):
    command = app.find("show")
    tester = CommandTester(command)

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

    installed.add_package(cachy_020)
    repo.add_package(cachy_020)

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

    tester.execute("--outdated")

    expected = ""

    assert expected == tester.io.fetch_output()
示例#21
0
def test_debug_resolve_git_dependency(app, repo):
    repo.add_package(get_package("pendulum", "2.0.3"))
    repo.add_package(get_package("cleo", "0.6.5"))

    command = app.find("debug:resolve")
    tester = CommandTester(command)

    tester.execute([
        ("command", command.get_name()),
        ("package", ["git+https://github.com/demo/demo.git"]),
    ])

    expected = """\
Resolving dependencies...

Resolution results:

  - pendulum (2.0.3)
  - demo (0.1.2)
"""

    assert tester.get_display(True) == expected
示例#22
0
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()
    expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = "This is a description"
authors = ["Your Name <*****@*****.**>"]
license = "MIT"

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

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

    assert expected in output
示例#23
0
    def test_standardize_2(self):
        table = [["A", "B", "C"], [1, 2, 3], [4, 5, 6]]
        dialect = SimpleDialect(delimiter=";", quotechar="", escapechar="")
        tmpfname = self._build_file(table, dialect)

        tmpfd, tmpoutname = tempfile.mkstemp(suffix=".csv")
        os.close(tmpfd)

        application = build_application()
        command = application.find("standardize")
        tester = CommandTester(command)
        tester.execute(f"-o {tmpoutname} {tmpfname}")

        exp = "A,B,C\n1,2,3\n4,5,6\n"
        with open(tmpoutname, "r") as fp:
            output = fp.read()

        try:
            self.assertEqual(exp, output)
        finally:
            os.unlink(tmpfname)
            os.unlink(tmpoutname)
示例#24
0
文件: test_add.py 项目: zhyr/poetry
def test_add_file_constraint_sdist(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"]),
            ("--path", "../distributions/demo-0.1.0.tar.gz"),
        ]
    )

    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.0 ../distributions/demo-0.1.0.tar.gz)
"""

    assert tester.get_display(True) == expected

    assert len(installer.installs) == 2

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

    assert "demo" in content["dependencies"]
    assert content["dependencies"]["demo"] == {
        "path": "../distributions/demo-0.1.0.tar.gz"
    }
示例#25
0
def test_add_url_constraint_wheel(app, repo, installer, mocker):
    p = mocker.patch("poetry.utils._compat.Path.cwd")
    p.return_value = Path(__file__) / ".."

    command = app.find("add")
    tester = CommandTester(command)

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

    tester.execute(
        "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl"
    )

    expected = """\

Updating dependencies
Resolving dependencies...

Writing lock file


Package operations: 2 installs, 0 updates, 0 removals

  - Installing pendulum (1.4.4)
  - Installing demo (0.1.0 https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl)
"""

    assert expected == tester.io.fetch_output()

    assert len(installer.installs) == 2

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

    assert "demo" in content["dependencies"]
    assert content["dependencies"]["demo"] == {
        "url":
        "https://python-poetry.org/distributions/demo-0.1.0-py2.py3-none-any.whl"
    }
示例#26
0
def test_empty_license(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)
    inputs = [
        "my-package",  # Package name
        "1.2.3",  # Version
        "",  # Description
        "n",  # Author
        "",  # License
        "",  # Python
        "n",  # Interactive packages
        "n",  # Interactive dev packages
        "\n",  # Generate
    ]
    tester.execute(inputs="\n".join(inputs))

    expected = """\
[tool.poetry]
name = "my-package"
version = "1.2.3"
description = ""
authors = ["Your Name <*****@*****.**>"]

[tool.poetry.dependencies]
python = "^{python}"

[tool.poetry.dev-dependencies]
""".format(
        python=".".join(str(c) for c in sys.version_info[:2])
    )

    assert expected in tester.io.fetch_output()
示例#27
0
def test_command(app, mocker, tmp_dir):
    poetry_file = os.path.join(tmp_dir, 'poetry.toml')
    readme = os.path.join(tmp_dir, 'README.rst')
    fixtures = os.path.join(os.path.dirname(__file__), '..', 'fixtures')
    shutil.copy(os.path.join(fixtures, 'poetry.toml'), poetry_file)
    shutil.copy(os.path.join(fixtures, 'README.rst'), readme)
    requirements_file = os.path.join(tmp_dir, 'requirements.txt')

    resolve = mocker.patch('piptools.resolver.Resolver.resolve')
    reverse_dependencies = mocker.patch(
        'piptools.resolver.Resolver.reverse_dependencies')
    resolve.return_value = [InstallRequirement.from_line('pendulum==1.2.0')]
    reverse_dependencies.return_value = {}
    poet = Poet(poetry_file)
    poet_prop = mocker.patch('poet.console.commands.command.Command.poet',
                             poet)
    poet_prop.return_value = poet

    command = app.find('make:requirements')
    tester = CommandTester(command)
    tester.execute([('command', command.name)])

    expected = """
 - Resolving dependencies
 - Created requirements.txt file
"""

    output = tester.get_display()

    assert expected == output

    assert os.path.exists(requirements_file)

    content = """pendulum==1.2.0
"""

    with open(requirements_file) as f:
        assert content == f.read()
示例#28
0
def test_debug_resolve_gives_resolution_results(app, repo):
    command = app.find("debug:resolve")
    tester = CommandTester(command)

    cachy2 = get_package("cachy", "0.2.0")
    cachy2.add_dependency("msgpack-python", ">=0.5 <0.6")

    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()), ("package", ["cachy"])])

    expected = """\
Resolving dependencies...

Resolution results:

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

    assert tester.get_display(True) == expected
示例#29
0
def test_activated(app, tmp_dir):
    app.poetry.config.merge({"virtualenvs": {"path": str(tmp_dir)}})

    venv_name = EnvManager.generate_env_name("simple-project",
                                             str(app.poetry.file.parent))
    (Path(tmp_dir) / "{}-py3.7".format(venv_name)).mkdir()
    (Path(tmp_dir) / "{}-py3.6".format(venv_name)).mkdir()

    envs_file = TomlFile(Path(tmp_dir) / "envs.toml")
    doc = tomlkit.document()
    doc[venv_name] = {"minor": "3.7", "patch": "3.7.0"}
    envs_file.write(doc)

    command = app.find("env list")
    tester = CommandTester(command)
    tester.execute()

    expected = """\
{}-py3.6
{}-py3.7 (Activated)
""".format(venv_name, venv_name)

    assert expected == tester.io.fetch_output()
示例#30
0
def test_check_invalid(app):
    app._poetry = Poetry.create(
        Path(__file__).parent.parent.parent / "fixtures" / "invalid_pyproject"
    )
    command = app.find("check")
    tester = CommandTester(command)

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

    if PY2:
        expected = """\
Error: u'description' is a required property
Error: INVALID is not a valid license
Warning: A wildcard Python dependency is ambiguous. Consider specifying a more explicit one.
"""
    else:
        expected = """\
Error: 'description' is a required property
Error: INVALID is not a valid license
Warning: A wildcard Python dependency is ambiguous. Consider specifying a more explicit one.
"""

    assert tester.get_display(True) == expected