Skip to content

Commit 77d7c50

Browse files
committed
Add end-to-end test for uv constraint-dependencies from -c chain
1 parent 1ec5ae4 commit 77d7c50

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

‎tests/test_uv.py‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,38 @@ def test_empty_constraints_removes_stale_managed_array(tmp_path, monkeypatch):
600600

601601
doc = tomlkit.parse((tmp_path / "pyproject.toml").read_text())
602602
assert "constraint-dependencies" not in doc["tool"]["uv"]
603+
604+
605+
def test_end_to_end_constraint_chain(tmp_path, monkeypatch):
606+
monkeypatch.chdir(tmp_path)
607+
608+
# constraints chain: requirements.txt -> -c constraints.txt
609+
(tmp_path / "constraints.txt").write_text("Zope==6.0\nAccessControl==7.3\n")
610+
(tmp_path / "requirements.txt").write_text("-c constraints.txt\n")
611+
612+
mx_ini = "[settings]\nrequirements-in = requirements.txt\n" "version-overrides =\n AccessControl==7.4\n"
613+
(tmp_path / "mx.ini").write_text(mx_ini)
614+
615+
(tmp_path / "pyproject.toml").write_text(
616+
'[project]\nname = "test"\ndependencies = []\n\n[tool.uv]\nmanaged = true\n'
617+
)
618+
619+
from mxdev.processing import read
620+
621+
config = Configuration("mx.ini")
622+
state = State(config)
623+
read(state) # populates state.constraints from the chain
624+
625+
hook = UvPyprojectUpdater()
626+
hook.write(state)
627+
628+
content = (tmp_path / "pyproject.toml").read_text()
629+
assert "# begin constraints from: constraints.txt" in content
630+
doc = tomlkit.parse(content)
631+
cdeps = list(doc["tool"]["uv"]["constraint-dependencies"])
632+
# Zope is constrained; AccessControl is overridden -> commented out by read(),
633+
# so it must NOT appear as an active constraint entry.
634+
assert "Zope==6.0" in cdeps
635+
assert "AccessControl==7.3" not in cdeps
636+
# The override itself is carried by override-dependencies.
637+
assert list(doc["tool"]["uv"]["override-dependencies"]) == ["AccessControl==7.4"]

0 commit comments

Comments
 (0)