Skip to content

Commit

Permalink
black and pylint
Browse files Browse the repository at this point in the history
  • Loading branch information
Spencer Putt committed Dec 22, 2024
1 parent 25fb4b6 commit c6afc51
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions tests/test_dists.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,32 @@ def test_big_circular_invalidate() -> None:
for node in dists:
assert node.complete


def test_base_plugin_circular_completed() -> None:
"""Create a root and plugin-style circular dependency and ensure that the graph is completed."""
dists = DistributionCollection()
metadata_root = DistInfo("root", "1.0.0", reqs=pkg_resources.parse_requirements(["root-c", "root-a", "root-b"]))
metadata_root_a = DistInfo("root-a", "1.0.0", reqs=pkg_resources.parse_requirements(["root", "dep-a"]))
metadata_root = DistInfo(
"root",
"1.0.0",
reqs=pkg_resources.parse_requirements(["root-c", "root-a", "root-b"]),
)
metadata_root_a = DistInfo(
"root-a", "1.0.0", reqs=pkg_resources.parse_requirements(["root", "dep-a"])
)
metadata_dep_a = DistInfo("dep-a", "1.0.0", reqs=[])
metadata_root_b = DistInfo("root-b", "1.0.0", reqs=pkg_resources.parse_requirements(["root", "dep-b", "common"]))
metadata_root_b = DistInfo(
"root-b",
"1.0.0",
reqs=pkg_resources.parse_requirements(["root", "dep-b", "common"]),
)
metadata_dep_b = DistInfo("dep-b", "1.0.0", reqs=[])
metadata_root_c = DistInfo("root-c", "1.0.0", reqs=pkg_resources.parse_requirements(["dep-c"]))
metadata_root_c = DistInfo(
"root-c", "1.0.0", reqs=pkg_resources.parse_requirements(["dep-c"])
)
metadata_dep_c = DistInfo("dep-c", "1.0.0", reqs=[])
metadata_common = DistInfo("common", "1.0.0", reqs=pkg_resources.parse_requirements(["root", "dep-a"]))
metadata_common = DistInfo(
"common", "1.0.0", reqs=pkg_resources.parse_requirements(["root", "dep-a"])
)

root_node = dists.add_dist(metadata_root, None, Requirement.parse("root"))
a_node = dists.add_dist(metadata_root_a, root_node, Requirement.parse("root-a"))
Expand All @@ -260,15 +275,22 @@ def test_base_plugin_circular_completed() -> None:
dists.add_dist(metadata_dep_b, b_node, Requirement.parse("dep-b"))
c_node = dists.add_dist(metadata_root_c, root_node, Requirement.parse("root-c"))
dists.add_dist(metadata_dep_c, c_node, Requirement.parse("dep-c"))

assert list(dists["root-c"].dependencies) == [dists["dep-c"]]
assert list(dists["root-c"].reverse_deps) == [dists["root"]]

assert set(dists["common"].dependencies) == {dists["root"], dists["dep-a"]}
assert list(dists["common"].reverse_deps) == [dists["root-b"]]

assert _get_cycle(dists["root"], set(dists["root"].dependencies)) == {dists["root"], dists["root-a"], dists["root-b"], dists["common"]}
assert _get_cycle(dists["dep-c"], set(dists["dep-c"].dependencies)) == {dists["dep-c"]}
assert _get_cycle(dists["root"], set(dists["root"].dependencies)) == {
dists["root"],
dists["root-a"],
dists["root-b"],
dists["common"],
}
assert _get_cycle(dists["dep-c"], set(dists["dep-c"].dependencies)) == {
dists["dep-c"]
}

for node in dists:
assert node.complete, str(node)

0 comments on commit c6afc51

Please sign in to comment.