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 error in "poetry config" when Poetry is not configured in pyproject.toml (3084) #3172

Merged
merged 2 commits into from
Oct 11, 2020
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 poetry/console/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from cleo import argument
from cleo import option

from poetry.core.pyproject import PyProjectException
from poetry.core.toml.file import TOMLFile
from poetry.factory import Factory

Expand Down Expand Up @@ -80,7 +81,7 @@ def handle(self):
local_config_file = TOMLFile(self.poetry.file.parent / "poetry.toml")
if local_config_file.exists():
config.merge(local_config_file.read())
except RuntimeError:
except (RuntimeError, PyProjectException):
local_config_file = TOMLFile(Path.cwd() / "poetry.toml")

if self.option("local"):
Expand Down
11 changes: 11 additions & 0 deletions tests/console/commands/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest

from poetry.config.config_source import ConfigSource
from poetry.core.pyproject import PyProjectException
from poetry.factory import Factory


Expand All @@ -12,6 +13,16 @@ def tester(command_tester_factory):
return command_tester_factory("config")


def test_show_config_with_local_config_file_empty(tester, mocker):
mocker.patch(
"poetry.factory.Factory.create_poetry",
side_effect=PyProjectException("[tool.poetry] section not found"),
)
tester.execute()

assert "" == tester.io.fetch_output()


def test_list_displays_default_value_if_not_set(tester, config):
tester.execute("--list")

Expand Down