"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/console/commands/test_show.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_show.py  (poetry-1.1.15):test_show.py  (poetry-1.2.0)
from __future__ import annotations
from typing import TYPE_CHECKING
import pytest import pytest
from clikit.formatter.ansi_formatter import AnsiFormatter from poetry.core.packages.dependency_group import MAIN_GROUP
from poetry.core.packages.dependency_group import DependencyGroup
from poetry.factory import Factory from poetry.factory import Factory
from tests.helpers import MOCK_DEFAULT_GIT_REVISION
from tests.helpers import get_package from tests.helpers import get_package
if TYPE_CHECKING:
from cleo.testers.command_tester import CommandTester
from poetry.poetry import Poetry
from poetry.repositories import Repository
from tests.helpers import TestRepository
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("show") return command_tester_factory("show")
def test_show_basic_with_installed_packages(tester, poetry, installed): def test_show_basic_with_installed_packages(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
poetry.package.add_dependency( poetry.package.add_dependency(
Factory.create_dependency("pytest", "^3.7.3", category="dev") Factory.create_dependency("pytest", "^3.7.3", groups=["dev"])
) )
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
pytest_373 = get_package("pytest", "3.7.3") pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package" pytest_373.description = "Pytest package"
skipping to change at line 84 skipping to change at line 100
) )
tester.execute() tester.execute()
expected = """\ expected = """\
cachy 0.1.0 Cachy package cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package pytest 3.7.3 Pytest package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def _configure_project_with_groups(poetry: Poetry, installed: Repository) -> Non
e:
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency_group(DependencyGroup(name="time", optional=Tr
ue))
poetry.package.add_dependency(
Factory.create_dependency("pendulum", "^2.0.0", groups=["time"])
)
poetry.package.add_dependency(
Factory.create_dependency("pytest", "^3.7.3", groups=["test"])
)
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"
pendulum_200.category = "dev"
pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package"
pytest_373.category = "dev"
installed.add_package(cachy_010)
installed.add_package(pendulum_200)
installed.add_package(pytest_373)
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": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
{
"name": "pytest",
"version": "3.7.3",
"description": "Pytest package",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "pytest": []},
},
}
)
@pytest.mark.parametrize(
("options", "expected"),
[
(
"",
"""\
cachy 0.1.0 Cachy package
pytest 3.7.3 Pytest package
""",
),
(
"--with time",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package
""",
),
(
"--without test",
"""\
cachy 0.1.0 Cachy package
""",
),
(
f"--without {MAIN_GROUP}",
"""\
pytest 3.7.3 Pytest package
""",
),
(
f"--only {MAIN_GROUP}",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--no-dev",
"""\
cachy 0.1.0 Cachy package
""",
),
(
"--with time --without test",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
""",
),
(
f"--with time --without {MAIN_GROUP},test",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--only time",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--only time --with test",
"""\
pendulum 2.0.0 Pendulum package
""",
),
(
"--with time",
"""\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package
""",
),
],
)
def test_show_basic_with_group_options(
options: str,
expected: str,
tester: CommandTester,
poetry: Poetry,
installed: Repository,
):
_configure_project_with_groups(poetry, installed)
tester.execute(options)
assert tester.io.fetch_output() == expected
def test_show_basic_with_installed_packages_single(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy 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": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": []},
},
}
)
tester.execute("cachy")
assert [
"name : cachy",
"version : 0.1.0",
"description : Cachy package",
] == [line.strip() for line in tester.io.fetch_output().splitlines()]
def test_show_basic_with_installed_packages_single_canonicalized(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("foo-bar", "^0.1.0")
)
foo_bar = get_package("foo-bar", "0.1.0")
foo_bar.description = "Foobar package"
installed.add_package(foo_bar)
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "foo-bar",
"version": "0.1.0",
"description": "Foobar package",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"foo-bar": []},
},
}
)
tester.execute("Foo_Bar")
assert [
"name : foo-bar",
"version : 0.1.0",
"description : Foobar package",
] == [line.strip() for line in tester.io.fetch_output().splitlines()]
def test_show_basic_with_not_installed_packages_non_decorated( def test_show_basic_with_not_installed_packages_non_decorated(
tester, poetry, installed tester: CommandTester, poetry: Poetry, installed: Repository
): ):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 139 skipping to change at line 397
} }
) )
tester.execute() tester.execute()
expected = """\ expected = """\
cachy 0.1.0 Cachy package cachy 0.1.0 Cachy package
pendulum (!) 2.0.0 Pendulum package pendulum (!) 2.0.0 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_basic_with_not_installed_packages_decorated(tester, poetry, instal def test_show_basic_with_not_installed_packages_decorated(
led): tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
installed.add_package(cachy_010) installed.add_package(cachy_010)
skipping to change at line 185 skipping to change at line 445
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": []}, "hashes": {"cachy": [], "pendulum": []},
}, },
} }
) )
tester.io.set_formatter(AnsiFormatter(forced=True)) tester.execute(decorated=True)
tester.execute()
expected = """\ expected = """\
\033[36mcachy \033[0m \033[1m0.1.0\033[0m Cachy package \033[36mcachy \033[39m \033[39;1m0.1.0\033[39;22m Cachy package
\033[31mpendulum\033[0m \033[1m2.0.0\033[0m Pendulum package \033[31mpendulum\033[39m \033[39;1m2.0.0\033[39;22m Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_latest_non_decorated(tester, poetry, installed, repo): def test_show_latest_non_decorated(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 257 skipping to change at line 521
} }
) )
tester.execute("--latest") tester.execute("--latest")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
pendulum 2.0.0 2.0.1 Pendulum package pendulum 2.0.0 2.0.1 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_latest_decorated(tester, poetry, installed, repo): def test_show_latest_decorated(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 314 skipping to change at line 583
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": []}, "hashes": {"cachy": [], "pendulum": []},
}, },
} }
) )
tester.io.set_formatter(AnsiFormatter(forced=True)) tester.execute("--latest", decorated=True)
tester.execute("--latest")
expected = """\ expected = """\
\033[36mcachy \033[0m \033[1m0.1.0\033[0m \033[33m0.2.0\033[0m Cachy package \033[36mcachy \033[39m \033[39;1m0.1.0\033[39;22m\
\033[36mpendulum\033[0m \033[1m2.0.0\033[0m \033[31m2.0.1\033[0m Pendulum packag \033[33m0.2.0\033[39m Cachy package
e \033[36mpendulum\033[39m \033[39;1m2.0.0\033[39;22m\
\033[31m2.0.1\033[39m Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_outdated(tester, poetry, installed, repo): def test_show_outdated(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 382 skipping to change at line 657
}, },
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_outdated_with_only_up_to_date_packages(tester, poetry, installed, def test_show_outdated_with_only_up_to_date_packages(
repo): tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
installed.add_package(cachy_020) installed.add_package(cachy_020)
repo.add_package(cachy_020) repo.add_package(cachy_020)
poetry.locker.mock_lock_data( poetry.locker.mock_lock_data(
{ {
"package": [ "package": [
{ {
skipping to change at line 418 skipping to change at line 698
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": []}, "hashes": {"cachy": []},
}, },
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = "" expected = ""
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_outdated_has_prerelease_but_not_allowed(tester, poetry, installed, def test_show_outdated_has_prerelease_but_not_allowed(
repo): tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
cachy_030dev = get_package("cachy", "0.3.0.dev123") cachy_030dev = get_package("cachy", "0.3.0.dev123")
cachy_030dev.description = "Cachy package" cachy_030dev.description = "Cachy package"
skipping to change at line 483 skipping to change at line 768
}, },
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_outdated_has_prerelease_and_allowed(tester, poetry, installed, rep def test_show_outdated_has_prerelease_and_allowed(
o): tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency( poetry.package.add_dependency(
Factory.create_dependency( Factory.create_dependency(
"cachy", {"version": "^0.1.0", "allow-prereleases": True} "cachy", {"version": ">=0.0.1", "allow-prereleases": True}
) )
) )
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010dev = get_package("cachy", "0.1.0.dev1") cachy_010dev = get_package("cachy", "0.1.0.dev1")
cachy_010dev.description = "Cachy package" cachy_010dev.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
cachy_030dev = get_package("cachy", "0.3.0.dev123") cachy_030dev = get_package("cachy", "0.3.0.dev123")
cachy_030dev.description = "Cachy package" cachy_030dev.description = "Cachy package"
skipping to change at line 552 skipping to change at line 842
}, },
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.1.0.dev1 0.3.0.dev123 Cachy package cachy 0.1.0.dev1 0.3.0.dev123 Cachy package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_outdated_formatting(tester, poetry, installed, repo): def test_show_outdated_formatting(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 616 skipping to change at line 911
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
pendulum 2.0.0 2.0.1 Pendulum package pendulum 2.0.0 2.0.1 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
@pytest.mark.parametrize("project_directory", ["project_with_local_dependencies" @pytest.mark.parametrize(
]) ("project_directory", "required_fixtures"),
def test_show_outdated_local_dependencies(tester, poetry, installed, repo): [
(
"project_with_local_dependencies",
["distributions/demo-0.1.0-py2.py3-none-any.whl", "project_with_setu
p"],
),
],
)
def test_show_outdated_local_dependencies(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
cachy_030 = get_package("cachy", "0.3.0") cachy_030 = get_package("cachy", "0.3.0")
cachy_030.description = "Cachy package" cachy_030.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
demo_010 = get_package("demo", "0.1.0") demo_010 = get_package("demo", "0.1.0")
demo_010.description = "" demo_010.description = ""
my_package_012 = get_package("project-with-setup", "0.1.2") my_package_011 = get_package("project-with-setup", "0.1.1")
my_package_012.description = "Demo project." my_package_011.description = "Demo project."
installed.add_package(cachy_020) installed.add_package(cachy_020)
installed.add_package(pendulum_200) installed.add_package(pendulum_200)
installed.add_package(demo_010) installed.add_package(demo_010)
installed.add_package(my_package_012) installed.add_package(my_package_011)
repo.add_package(cachy_020) repo.add_package(cachy_020)
repo.add_package(cachy_030) repo.add_package(cachy_030)
repo.add_package(pendulum_200) repo.add_package(pendulum_200)
poetry.locker.mock_lock_data( poetry.locker.mock_lock_data(
{ {
"package": [ "package": [
{ {
"name": "cachy", "name": "cachy",
skipping to change at line 723 skipping to change at line 1031
}, },
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.2.0 0.3.0 cachy 0.2.0 0.3.0
project-with-setup 0.1.1 ../project_with_setup 0.1.2 ../project_with_setup project-with-setup 0.1.1 ../project_with_setup 0.1.2 ../project_with_setup
""" """
assert expected.rstrip() == "\n".join( assert (
line.rstrip() for line in tester.io.fetch_output().splitlines() "\n".join(line.rstrip() for line in tester.io.fetch_output().splitlines(
))
== expected.rstrip()
) )
@pytest.mark.parametrize("project_directory", ["project_with_git_dev_dependency" ]) @pytest.mark.parametrize("project_directory", ["project_with_git_dev_dependency" ])
def test_show_outdated_git_dev_dependency(tester, poetry, installed, repo): def test_show_outdated_git_dev_dependency(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
demo_011 = get_package("demo", "0.1.1") demo_011 = get_package("demo", "0.1.1")
demo_011.description = "Demo package" demo_011.description = "Demo package"
skipping to change at line 787 skipping to change at line 1101
"name": "demo", "name": "demo",
"version": "0.1.1", "version": "0.1.1",
"description": "Demo package", "description": "Demo package",
"category": "dev", "category": "dev",
"optional": False, "optional": False,
"platform": "*", "platform": "*",
"python-versions": "*", "python-versions": "*",
"checksum": [], "checksum": [],
"source": { "source": {
"type": "git", "type": "git",
"reference": "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24", "reference": MOCK_DEFAULT_GIT_REVISION,
"resolved_reference": "9cf87a285a2d3fbb0b9fa621997b3acc3 "resolved_reference": MOCK_DEFAULT_GIT_REVISION,
631ed24",
"url": "https://github.com/demo/demo.git", "url": "https://github.com/demo/demo.git",
}, },
}, },
{ {
"name": "pytest", "name": "pytest",
"version": "3.4.3", "version": "3.4.3",
"description": "Pytest", "description": "Pytest",
"category": "dev", "category": "dev",
"optional": False, "optional": False,
"platform": "*", "platform": "*",
skipping to change at line 819 skipping to change at line 1133
} }
) )
tester.execute("--outdated") tester.execute("--outdated")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
demo 0.1.1 9cf87a2 0.1.2 9cf87a2 Demo package demo 0.1.1 9cf87a2 0.1.2 9cf87a2 Demo package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
@pytest.mark.parametrize("project_directory", ["project_with_git_dev_dependency" ]) @pytest.mark.parametrize("project_directory", ["project_with_git_dev_dependency" ])
def test_show_outdated_no_dev_git_dev_dependency(tester, poetry, installed, repo def test_show_outdated_no_dev_git_dev_dependency(
): tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
cachy_020 = get_package("cachy", "0.2.0") cachy_020 = get_package("cachy", "0.2.0")
cachy_020.description = "Cachy package" cachy_020.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
demo_011 = get_package("demo", "0.1.1") demo_011 = get_package("demo", "0.1.1")
demo_011.description = "Demo package" demo_011.description = "Demo package"
skipping to change at line 881 skipping to change at line 1200
"name": "demo", "name": "demo",
"version": "0.1.1", "version": "0.1.1",
"description": "Demo package", "description": "Demo package",
"category": "dev", "category": "dev",
"optional": False, "optional": False,
"platform": "*", "platform": "*",
"python-versions": "*", "python-versions": "*",
"checksum": [], "checksum": [],
"source": { "source": {
"type": "git", "type": "git",
"reference": "9cf87a285a2d3fbb0b9fa621997b3acc3631ed24", "reference": MOCK_DEFAULT_GIT_REVISION,
"url": "https://github.com/demo/pyproject-demo.git", "url": "https://github.com/demo/pyproject-demo.git",
}, },
}, },
{ {
"name": "pytest", "name": "pytest",
"version": "3.4.3", "version": "3.4.3",
"description": "Pytest", "description": "Pytest",
"category": "dev", "category": "dev",
"optional": False, "optional": False,
"platform": "*", "platform": "*",
skipping to change at line 905 skipping to change at line 1224
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "demo": [], "pytest": [] }, "hashes": {"cachy": [], "pendulum": [], "demo": [], "pytest": [] },
}, },
} }
) )
tester.execute("--outdated --no-dev") tester.execute("--outdated --without dev")
expected = """\ expected = """\
cachy 0.1.0 0.2.0 Cachy package cachy 0.1.0 0.2.0 Cachy package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_hides_incompatible_package(tester, poetry, installed, repo): def test_show_hides_incompatible_package(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
poetry.package.add_dependency( poetry.package.add_dependency(
Factory.create_dependency("cachy", {"version": "^0.1.0", "python": "< 2. 0"}) Factory.create_dependency("cachy", {"version": "^0.1.0", "python": "< 2. 0"})
) )
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" )) poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0" ))
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
skipping to change at line 966 skipping to change at line 1290
}, },
} }
) )
tester.execute() tester.execute()
expected = """\ expected = """\
pendulum 2.0.0 Pendulum package pendulum 2.0.0 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_all_shows_incompatible_package(tester, poetry, installed, repo): def test_show_all_shows_incompatible_package(
tester: CommandTester,
poetry: Poetry,
installed: Repository,
repo: TestRepository,
):
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
installed.add_package(pendulum_200) installed.add_package(pendulum_200)
poetry.locker.mock_lock_data( poetry.locker.mock_lock_data(
{ {
skipping to change at line 1018 skipping to change at line 1347
} }
) )
tester.execute("--all") tester.execute("--all")
expected = """\ expected = """\
cachy 0.1.0 Cachy package cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package pendulum 2.0.0 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_non_dev_with_basic_installed_packages(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0"
))
poetry.package.add_dependency(
Factory.create_dependency("pytest", "*", groups=["dev"])
)
def test_show_non_dev_with_basic_installed_packages(tester, poetry, installed):
cachy_010 = get_package("cachy", "0.1.0") cachy_010 = get_package("cachy", "0.1.0")
cachy_010.description = "Cachy package" cachy_010.description = "Cachy package"
pendulum_200 = get_package("pendulum", "2.0.0") pendulum_200 = get_package("pendulum", "2.0.0")
pendulum_200.description = "Pendulum package" pendulum_200.description = "Pendulum package"
pytest_373 = get_package("pytest", "3.7.3") pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package" pytest_373.description = "Pytest package"
pytest_373.category = "dev" pytest_373.category = "dev"
skipping to change at line 1078 skipping to change at line 1415
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "pytest": []}, "hashes": {"cachy": [], "pendulum": [], "pytest": []},
}, },
} }
) )
tester.execute("--no-dev") tester.execute("--without dev")
expected = """\ expected = """\
cachy 0.1.0 Cachy package cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package pendulum 2.0.0 Pendulum package
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_with_group_only(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0"
))
poetry.package.add_dependency(
Factory.create_dependency("pytest", "*", groups=["dev"])
)
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"
def test_show_tree(tester, poetry, installed): pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package"
pytest_373.category = "dev"
installed.add_package(cachy_010)
installed.add_package(pendulum_200)
installed.add_package(pytest_373)
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": [],
},
{
"name": "pytest",
"version": "3.7.3",
"description": "Pytest package",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "pytest": []},
},
}
)
tester.execute("--only dev")
expected = """\
pytest 3.7.3 Pytest package
"""
assert tester.io.fetch_output() == expected
def test_show_with_optional_group(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.1.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "^2.0.0"
))
group = DependencyGroup("dev", optional=True)
group.add_dependency(Factory.create_dependency("pytest", "*", groups=["dev"]
))
poetry.package.add_dependency_group(group)
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"
pytest_373 = get_package("pytest", "3.7.3")
pytest_373.description = "Pytest package"
pytest_373.category = "dev"
installed.add_package(cachy_010)
installed.add_package(pendulum_200)
installed.add_package(pytest_373)
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": [],
},
{
"name": "pytest",
"version": "3.7.3",
"description": "Pytest package",
"category": "dev",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "pytest": []},
},
}
)
tester.execute()
expected = """\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
"""
assert tester.io.fetch_output() == expected
tester.execute("--with dev")
expected = """\
cachy 0.1.0 Cachy package
pendulum 2.0.0 Pendulum package
pytest 3.7.3 Pytest package
"""
assert tester.io.fetch_output() == expected
def test_show_tree(tester: CommandTester, poetry: Poetry, installed: Repository)
:
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
cachy2 = get_package("cachy", "0.2.0") cachy2 = get_package("cachy", "0.2.0")
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0. 6")) cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0. 6"))
installed.add_package(cachy2) installed.add_package(cachy2)
poetry.locker.mock_lock_data( poetry.locker.mock_lock_data(
{ {
"package": [ "package": [
skipping to change at line 1129 skipping to change at line 1625
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "msgpack-python": []}, "hashes": {"cachy": [], "msgpack-python": []},
}, },
} }
) )
tester.execute("--tree") tester.execute("--tree", supports_utf8=False)
expected = """\ expected = """\
cachy 0.2.0 cachy 0.2.0
`-- msgpack-python >=0.5 <0.6 `-- msgpack-python >=0.5 <0.6
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_tree_no_dev(tester, poetry, installed): def test_show_tree_no_dev(tester: CommandTester, poetry: Poetry, installed: Repo sitory):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0")) poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
poetry.package.add_dependency( poetry.package.add_dependency(
Factory.create_dependency("pytest", "^6.1.0", category="dev") Factory.create_dependency("pytest", "^6.1.0", groups=["dev"])
) )
cachy2 = get_package("cachy", "0.2.0") cachy2 = get_package("cachy", "0.2.0")
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0. 6")) cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0. 6"))
installed.add_package(cachy2) installed.add_package(cachy2)
pytest = get_package("pytest", "6.1.1") pytest = get_package("pytest", "6.1.1")
installed.add_package(pytest) installed.add_package(pytest)
poetry.locker.mock_lock_data( poetry.locker.mock_lock_data(
skipping to change at line 1195 skipping to change at line 1691
], ],
"metadata": { "metadata": {
"python-versions": "*", "python-versions": "*",
"platform": "*", "platform": "*",
"content-hash": "123456789", "content-hash": "123456789",
"hashes": {"cachy": [], "msgpack-python": [], "pytest": []}, "hashes": {"cachy": [], "msgpack-python": [], "pytest": []},
}, },
} }
) )
tester.execute("--tree --no-dev") tester.execute("--tree --without dev")
expected = """\ expected = """\
cachy 0.2.0 cachy 0.2.0
`-- msgpack-python >=0.5 <0.6 └── msgpack-python >=0.5 <0.6
""" """
assert expected == tester.io.fetch_output() assert tester.io.fetch_output() == expected
def test_show_tree_why_package(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("a", "=0.0.1"))
a = get_package("a", "0.0.1")
installed.add_package(a)
a.add_dependency(Factory.create_dependency("b", "=0.0.1"))
b = get_package("b", "0.0.1")
a.add_dependency(Factory.create_dependency("c", "=0.0.1"))
installed.add_package(b)
c = get_package("c", "0.0.1")
installed.add_package(c)
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "a",
"version": "0.0.1",
"dependencies": {"b": "=0.0.1"},
"python-versions": "*",
"optional": False,
},
{
"name": "b",
"version": "0.0.1",
"dependencies": {"c": "=0.0.1"},
"python-versions": "*",
"optional": False,
},
{
"name": "c",
"version": "0.0.1",
"python-versions": "*",
"optional": False,
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"a": [], "b": [], "c": []},
},
}
)
tester.execute("--tree --why b")
expected = """\
a 0.0.1
└── b =0.0.1
└── c =0.0.1 \n"""
assert tester.io.fetch_output() == expected
def test_show_tree_why(tester: CommandTester, poetry: Poetry, installed: Reposit
ory):
poetry.package.add_dependency(Factory.create_dependency("a", "=0.0.1"))
a = get_package("a", "0.0.1")
installed.add_package(a)
a.add_dependency(Factory.create_dependency("b", "=0.0.1"))
b = get_package("b", "0.0.1")
a.add_dependency(Factory.create_dependency("c", "=0.0.1"))
installed.add_package(b)
c = get_package("c", "0.0.1")
installed.add_package(c)
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "a",
"version": "0.0.1",
"dependencies": {"b": "=0.0.1"},
"python-versions": "*",
"optional": False,
},
{
"name": "b",
"version": "0.0.1",
"dependencies": {"c": "=0.0.1"},
"python-versions": "*",
"optional": False,
},
{
"name": "c",
"version": "0.0.1",
"python-versions": "*",
"optional": False,
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"a": [], "b": [], "c": []},
},
}
)
tester.execute("--why")
# this has to be on a single line due to the padding whitespace, which gets
stripped
# by pre-commit.
expected = """a 0.0.1 \nb 0.0.1 from a \nc 0.0.1 from b \n"""
assert tester.io.fetch_output() == expected
def test_show_required_by_deps(
tester: CommandTester, poetry: Poetry, installed: Repository
):
poetry.package.add_dependency(Factory.create_dependency("cachy", "^0.2.0"))
poetry.package.add_dependency(Factory.create_dependency("pendulum", "2.0.0")
)
cachy2 = get_package("cachy", "0.2.0")
cachy2.add_dependency(Factory.create_dependency("msgpack-python", ">=0.5 <0.
6"))
pendulum = get_package("pendulum", "2.0.0")
pendulum.add_dependency(Factory.create_dependency("CachY", "^0.2.0"))
installed.add_package(cachy2)
installed.add_package(pendulum)
poetry.locker.mock_lock_data(
{
"package": [
{
"name": "cachy",
"version": "0.2.0",
"description": "",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"dependencies": {"msgpack-python": ">=0.5 <0.6"},
},
{
"name": "pendulum",
"version": "2.0.0",
"description": "Pendulum package",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
"dependencies": {"cachy": ">=0.2.0 <0.3.0"},
},
{
"name": "msgpack-python",
"version": "0.5.1",
"description": "",
"category": "main",
"optional": False,
"platform": "*",
"python-versions": "*",
"checksum": [],
},
],
"metadata": {
"python-versions": "*",
"platform": "*",
"content-hash": "123456789",
"hashes": {"cachy": [], "pendulum": [], "msgpack-python": []},
},
}
)
tester.execute("cachy")
expected = """\
name : cachy
version : 0.2.0
description :
dependencies
- msgpack-python >=0.5 <0.6
required by
- pendulum >=0.2.0 <0.3.0
""".splitlines()
actual = [line.rstrip() for line in tester.io.fetch_output().splitlines()]
assert actual == expected
def test_show_errors_without_lock_file(tester: CommandTester, poetry: Poetry):
assert not poetry.locker.lock.exists()
tester.execute()
expected = "Error: poetry.lock not found. Run `poetry lock` to create it.\n"
assert tester.io.fetch_error() == expected
assert tester.status_code == 1
 End of changes. 57 change blocks. 
69 lines changed or deleted 567 lines changed or added

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