Skip to content

Commit 9c6fbf6

Browse files
authored
feat: Respect uv_resolution in uv-venv-lock-runner (#205)
1 parent 5baef0a commit 9c6fbf6

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/tox_uv/_run_lock.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ def _setup_env(self) -> None: # noqa: C901
8282
]
8383
if self.conf["uv_python_preference"] != "none":
8484
cmd.extend(("--python-preference", self.conf["uv_python_preference"]))
85+
if self.conf["uv_resolution"]:
86+
cmd.extend(("--resolution", self.conf["uv_resolution"]))
8587
for extra in cast("set[str]", sorted(self.conf["extras"])):
8688
cmd.extend(("--extra", extra))
8789
groups = sorted(self.conf["dependency_groups"])

tests/test_tox_uv_lock.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,3 +609,54 @@ def test_skip_uv_package_skip(tox_project: ToxProjectCreator, monkeypatch: pytes
609609
),
610610
]
611611
assert calls == expected
612+
613+
614+
@pytest.mark.usefixtures("clear_python_preference_env_var")
615+
def test_uv_lock_ith_resolution(tox_project: ToxProjectCreator) -> None:
616+
project = tox_project({
617+
"tox.ini": """
618+
[testenv]
619+
runner = uv-venv-lock-runner
620+
uv_resolution = highest
621+
"""
622+
})
623+
execute_calls = project.patch_execute(lambda r: 0 if r.run_id != "venv" else None)
624+
result = project.run("run", "--notest")
625+
result.assert_success()
626+
627+
calls = [(i[0][0].conf.name, i[0][3].run_id, i[0][3].cmd) for i in execute_calls.call_args_list]
628+
uv = find_uv_bin()
629+
expected = [
630+
(
631+
"py",
632+
"venv",
633+
[
634+
uv,
635+
"venv",
636+
"-p",
637+
sys.executable,
638+
"--allow-existing",
639+
"--python-preference",
640+
"system",
641+
str(project.path / ".tox" / "py"),
642+
],
643+
),
644+
(
645+
"py",
646+
"uv-sync",
647+
[
648+
"uv",
649+
"sync",
650+
"--locked",
651+
"--python-preference",
652+
"system",
653+
"--resolution",
654+
"highest",
655+
"-p",
656+
sys.executable,
657+
],
658+
),
659+
]
660+
assert len(calls) == len(expected)
661+
for i in range(len(calls)):
662+
assert calls[i] == expected[i]

0 commit comments

Comments
 (0)