Skip to content

Commit 5baef0a

Browse files
authored
fix: Accept both pip_pre and uv_resolution (#204)
1 parent 0cee5f2 commit 5baef0a

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/tox_uv/_installer.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,12 @@ def post_process_install_command(self, cmd: Command) -> Command:
7878
if uv_resolution:
7979
install_command.extend(("--resolution", uv_resolution))
8080
else:
81+
opts: list[str] = []
8182
if pip_pre:
82-
install_command[opts_at] = "--prerelease"
83-
install_command.insert(opts_at + 1, "allow")
83+
opts.extend(("--prerelease", "allow"))
8484
if uv_resolution:
85-
install_command[opts_at] = "--resolution"
86-
install_command.insert(opts_at + 1, uv_resolution)
87-
if not (pip_pre or uv_resolution):
88-
install_command.pop(opts_at)
85+
opts.extend(("--resolution", uv_resolution))
86+
install_command[opts_at : opts_at + 1] = opts
8987
return cmd
9088

9189
def install(self, arguments: Any, section: str, of_type: str) -> None: # noqa: ANN401

tests/test_tox_uv_installer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,27 @@ def test_uv_install_with_resolution_strategy_custom_install_cmd(tox_project: Tox
9999
result.assert_success()
100100

101101
assert execute_calls.call_args[0][3].cmd[2:] == ["install", "tomli>=2.0.1", "--resolution", "lowest-direct"]
102+
103+
104+
def test_uv_install_with_resolution_strategy_and_pip_pre(tox_project: ToxProjectCreator) -> None:
105+
project = tox_project({
106+
"tox.ini": """
107+
[testenv]
108+
deps = tomli>=2.0.1
109+
package = skip
110+
uv_resolution = lowest-direct
111+
pip_pre = true
112+
"""
113+
})
114+
execute_calls = project.patch_execute(lambda r: 0 if "install" in r.run_id else None)
115+
result = project.run("-vv")
116+
result.assert_success()
117+
assert execute_calls.call_args[0][3].cmd[2:] == [
118+
"install",
119+
"--prerelease",
120+
"allow",
121+
"--resolution",
122+
"lowest-direct",
123+
"tomli>=2.0.1",
124+
"-v",
125+
]

0 commit comments

Comments
 (0)