"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/console/commands/env/test_remove.py" between
poetry-1.1.15.tar.gz and poetry-1.2.0.tar.gz

About: Poetry is a tool for dependency management and packaging in Python.

test_remove.py  (poetry-1.1.15):test_remove.py  (poetry-1.2.0)
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest import pytest
from poetry.core.semver.version import Version from poetry.core.semver.version import Version
from tests.console.commands.env.helpers import check_output_wrapper from tests.console.commands.env.helpers import check_output_wrapper
if TYPE_CHECKING:
from pathlib import Path
from cleo.testers.command_tester import CommandTester
from pytest_mock import MockerFixture
from tests.types import CommandTesterFactory
@pytest.fixture @pytest.fixture
def tester(command_tester_factory): def tester(command_tester_factory: CommandTesterFactory) -> CommandTester:
return command_tester_factory("env remove") return command_tester_factory("env remove")
def test_remove_by_python_version( def test_remove_by_python_version(
mocker, tester, venvs_in_cache_dirs, venv_name, venv_cache mocker: MockerFixture,
tester: CommandTester,
venvs_in_cache_dirs: list[str],
venv_name: str,
venv_cache: Path,
): ):
check_output = mocker.patch( check_output = mocker.patch(
"poetry.utils._compat.subprocess.check_output", "subprocess.check_output",
side_effect=check_output_wrapper(Version.parse("3.6.6")), side_effect=check_output_wrapper(Version.parse("3.6.6")),
) )
tester.execute("3.6") tester.execute("3.6")
assert check_output.called assert check_output.called
assert not (venv_cache / "{}-py3.6".format(venv_name)).exists() assert not (venv_cache / f"{venv_name}-py3.6").exists()
expected = "Deleted virtualenv: {}\n".format( expected = f"Deleted virtualenv: {venv_cache / venv_name}-py3.6\n"
(venv_cache / "{}-py3.6".format(venv_name)) assert tester.io.fetch_output() == expected
)
assert expected == tester.io.fetch_output()
def test_remove_by_name(tester, venvs_in_cache_dirs, venv_name, venv_cache): def test_remove_by_name(
tester: CommandTester,
venvs_in_cache_dirs: list[str],
venv_name: str,
venv_cache: Path,
):
expected = "" expected = ""
for name in venvs_in_cache_dirs: for name in venvs_in_cache_dirs:
tester.execute(name) tester.execute(name)
assert not (venv_cache / name).exists() assert not (venv_cache / name).exists()
expected += "Deleted virtualenv: {}\n".format((venv_cache / name)) expected += f"Deleted virtualenv: {venv_cache / name}\n"
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_remove_all(
tester: CommandTester,
venvs_in_cache_dirs: list[str],
venv_name: str,
venv_cache: Path,
):
expected = {""}
tester.execute("--all")
for name in venvs_in_cache_dirs:
assert not (venv_cache / name).exists()
expected.add(f"Deleted virtualenv: {venv_cache / name}")
assert set(tester.io.fetch_output().split("\n")) == expected
def test_remove_all_and_version(
tester: CommandTester,
venvs_in_cache_dirs: list[str],
venv_name: str,
venv_cache: Path,
):
expected = {""}
tester.execute(f"--all {venvs_in_cache_dirs[0]}")
for name in venvs_in_cache_dirs:
assert not (venv_cache / name).exists()
expected.add(f"Deleted virtualenv: {venv_cache / name}")
assert set(tester.io.fetch_output().split("\n")) == expected
def test_remove_multiple(
tester: CommandTester,
venvs_in_cache_dirs: list[str],
venv_name: str,
venv_cache: Path,
):
expected = {""}
removed_envs = venvs_in_cache_dirs[0:2]
remaining_envs = venvs_in_cache_dirs[2:]
tester.execute(" ".join(removed_envs))
for name in removed_envs:
assert not (venv_cache / name).exists()
expected.add(f"Deleted virtualenv: {venv_cache / name}")
for name in remaining_envs:
assert (venv_cache / name).exists()
assert set(tester.io.fetch_output().split("\n")) == expected
 End of changes. 11 change blocks. 
10 lines changed or deleted 30 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)