Skip to content

Commit 3d0e8b2

Browse files
committed
add tests for options
1 parent beeb7d9 commit 3d0e8b2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/poetry/console/commands/python/install.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ def handle(self) -> int:
9393
)
9494
return 1
9595

96-
request_title = f"<c1>{request}</> (<b>{impl}</>)"
96+
add_info = impl
97+
if free_threaded:
98+
add_info += ", free-threaded"
99+
request_title = f"<c1>{request}</> (<b>{add_info}</>)"
97100

98101
try:
99102
self.io.write(f"Downloading and installing {request_title} ... ")

tests/console/commands/python/test_python_install.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,28 @@ def test_install_reinstall(tester: CommandTester, mock_installer: MagicMock) ->
132132
"Downloading and installing 3.11 (cpython) ... Done\n"
133133
"Testing 3.11 (cpython) ... Done\n"
134134
)
135+
136+
137+
@pytest.mark.parametrize("free_threaded", [False, True])
138+
@pytest.mark.parametrize("implementation", ["cpython", "pypy"])
139+
def test_install_passes_options_to_installer(
140+
tester: CommandTester,
141+
mock_installer: MagicMock,
142+
free_threaded: bool,
143+
implementation: str,
144+
) -> None:
145+
mock_installer.return_value.exists.return_value = False
146+
147+
free_threaded_opt = "-t " if free_threaded else ""
148+
impl_opt = f"-i {implementation} "
149+
tester.execute(f"{free_threaded_opt}{impl_opt}3.13")
150+
151+
mock_installer.assert_called_once_with("3.13", implementation, free_threaded)
152+
mock_installer.return_value.install.assert_called_once()
153+
154+
assert tester.status_code == 0
155+
details = f"{implementation}, free-threaded" if free_threaded else implementation
156+
assert tester.io.fetch_output() == (
157+
f"Downloading and installing 3.13 ({details}) ... Done\n"
158+
f"Testing 3.13 ({details}) ... Done\n"
159+
)

0 commit comments

Comments
 (0)