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

fix poetry init #8655

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ def _validate_package(package: str | None) -> str | None:
return package

def _get_pool(self) -> RepositoryPool:
from poetry.config.config import Config
from poetry.repositories import RepositoryPool
from poetry.repositories.pypi_repository import PyPiRepository

Expand All @@ -489,7 +490,7 @@ def _get_pool(self) -> RepositoryPool:

if self._pool is None:
self._pool = RepositoryPool()
pool_size = self.poetry.config.installer_max_workers
pool_size = Config.create().installer_max_workers
self._pool.add_repository(PyPiRepository(pool_size=pool_size))

return self._pool
14 changes: 14 additions & 0 deletions tests/console/commands/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -1087,3 +1087,17 @@ def mock_check_output(cmd: str, *_: Any, **__: Any) -> str:
"""

assert expected in pyproject_file.read_text()


def test_get_pool(mocker: MockerFixture, source_dir: Path) -> None:
"""
Since we are mocking _get_pool() in the other tests, we at least should make
sure it works in general. See https://github.com/python-poetry/poetry/issues/8634.
"""
mocker.patch("pathlib.Path.cwd", return_value=source_dir)

app = Application()
command = app.find("init")
assert isinstance(command, InitCommand)
pool = command._get_pool()
assert pool.repositories
Loading