diff --git a/src/poetry/console/commands/init.py b/src/poetry/console/commands/init.py index cf59517b3a6..658b7a4a504 100644 --- a/src/poetry/console/commands/init.py +++ b/src/poetry/console/commands/init.py @@ -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 @@ -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 diff --git a/tests/console/commands/test_init.py b/tests/console/commands/test_init.py index 2a0a9bcaa25..44e472fbd70 100644 --- a/tests/console/commands/test_init.py +++ b/tests/console/commands/test_init.py @@ -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