Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order root extra dependencies #7375

Merged
merged 5 commits into from
Jan 20, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Create a test to reproduce the problem
  • Loading branch information
yeger00 committed Jan 20, 2023
commit 1dd1f6e2cb1873a1c2675cb58b153b2bd11a8743
37 changes: 37 additions & 0 deletions tests/packages/test_locker.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,43 @@ def test_locker_should_raise_an_error_if_lock_version_is_newer_and_not_allowed(
_ = locker.lock_data


def test_root_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage):
root_dir = Path(__file__).parent.parent.joinpath("fixtures")
Factory.create_dependency("B", "1.0.0", root_dir=root_dir)
Factory.create_dependency("C", "1.0.0", root_dir=root_dir)
package_first = Factory.create_dependency("first", "1.0.0", root_dir=root_dir)
package_second = Factory.create_dependency("second", "1.0.0", root_dir=root_dir)
package_third = Factory.create_dependency("third", "1.0.0", root_dir=root_dir)

root.extras = {
"C": [package_third, package_second, package_first],
"B": [package_first, package_second, package_third],
}
# root.requires[-1].activate()

locker.set_lock_data(root, [])

expected = f"""\
# {GENERATED_COMMENT}
package = []

[extras]
B = ["first", "second", "third"]
C = ["third", "second", "first"]

[metadata]
lock-version = "2.0"
python-versions = "*"
content-hash = "115cf985d932e9bf5f540555bbdd75decbb62cac81e399375fc19f6277f8c1d8"
""" # noqa: E800

with locker.lock.open(encoding="utf-8") as f:
content = f.read()

print(content)
assert content == expected


def test_extras_dependencies_are_ordered(locker: Locker, root: ProjectPackage):
package_a = get_package("A", "1.0.0")
package_a.add_dependency(
Expand Down