"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "tests/utils/test_extras.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_extras.py  (poetry-1.1.15):test_extras.py  (poetry-1.2.0)
from __future__ import annotations
import pytest import pytest
from poetry.core.packages import Package from poetry.core.packages.package import Package
from poetry.factory import Factory from poetry.factory import Factory
from poetry.utils.extras import get_extra_package_names from poetry.utils.extras import get_extra_package_names
_PACKAGE_FOO = Package("foo", "0.1.0") _PACKAGE_FOO = Package("foo", "0.1.0")
_PACKAGE_SPAM = Package("spam", "0.2.0") _PACKAGE_SPAM = Package("spam", "0.2.0")
_PACKAGE_BAR = Package("bar", "0.3.0") _PACKAGE_BAR = Package("bar", "0.3.0")
_PACKAGE_BAR.add_dependency(Factory.create_dependency("foo", "*")) _PACKAGE_BAR.add_dependency(Factory.create_dependency("foo", "*"))
# recursive dependency # recursive dependency
_PACKAGE_BAZ = Package("baz", "0.4.0") _PACKAGE_BAZ = Package("baz", "0.4.0")
_PACKAGE_BAZ.add_dependency(Factory.create_dependency("quix", "*")) _PACKAGE_BAZ.add_dependency(Factory.create_dependency("quix", "*"))
_PACKAGE_QUIX = Package("quix", "0.5.0") _PACKAGE_QUIX = Package("quix", "0.5.0")
_PACKAGE_QUIX.add_dependency(Factory.create_dependency("baz", "*")) _PACKAGE_QUIX.add_dependency(Factory.create_dependency("baz", "*"))
@pytest.mark.parametrize( @pytest.mark.parametrize(
"packages,extras,extra_names,expected_extra_package_names", ["packages", "extras", "extra_names", "expected_extra_package_names"],
[ [
# Empty edge case # Empty edge case
([], {}, [], []), ([], {}, [], []),
# Selecting no extras is fine # Selecting no extras is fine
([_PACKAGE_FOO], {}, [], []), ([_PACKAGE_FOO], {}, [], []),
# An empty extras group should return an empty list # An empty extras group should return an empty list
([_PACKAGE_FOO], {"group0": []}, ["group0"], []), ([_PACKAGE_FOO], {"group0": []}, ["group0"], []),
# Selecting an extras group should return the contained packages # Selecting an extras group should return the contained packages
( (
[_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR], [_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR],
skipping to change at line 41 skipping to change at line 44
["group0"], ["group0"],
["foo"], ["foo"],
), ),
# If a package has dependencies, we should also get their names # If a package has dependencies, we should also get their names
( (
[_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR], [_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR],
{"group0": ["bar"], "group1": ["spam"]}, {"group0": ["bar"], "group1": ["spam"]},
["group0"], ["group0"],
["bar", "foo"], ["bar", "foo"],
), ),
# Selecting multpile extras should get us the union of all package names # Selecting multiple extras should get us the union of all package names
( (
[_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR], [_PACKAGE_FOO, _PACKAGE_SPAM, _PACKAGE_BAR],
{"group0": ["bar"], "group1": ["spam"]}, {"group0": ["bar"], "group1": ["spam"]},
["group0", "group1"], ["group0", "group1"],
["bar", "foo", "spam"], ["bar", "foo", "spam"],
), ),
( (
[_PACKAGE_BAZ, _PACKAGE_QUIX], [_PACKAGE_BAZ, _PACKAGE_QUIX],
{"group0": ["baz"], "group1": ["quix"]}, {"group0": ["baz"], "group1": ["quix"]},
["group0", "group1"], ["group0", "group1"],
["baz", "quix"], ["baz", "quix"],
), ),
], ],
) )
def test_get_extra_package_names( def test_get_extra_package_names(
packages, extras, extra_names, expected_extra_package_names packages: list[Package],
): extras: dict[str, list[str]],
assert expected_extra_package_names == list( extra_names: list[str],
get_extra_package_names(packages, extras, extra_names) expected_extra_package_names: list[str],
) -> None:
assert (
list(get_extra_package_names(packages, extras, extra_names))
== expected_extra_package_names
) )
 End of changes. 5 change blocks. 
7 lines changed or deleted 14 lines changed or added

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