Skip to content

Commit

Permalink
Merge pull request #6491 from DavidBord/fix-5963-fail-elegantly-incor…
Browse files Browse the repository at this point in the history
…rect-config

fix-5963: fail elegantly
  • Loading branch information
xavfernandez authored May 13, 2019
2 parents bc8857d + a8c7295 commit 6387867
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions news/5963.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fail elegantly when trying to set an incorrectly formatted key in config.
6 changes: 6 additions & 0 deletions src/pip/_internal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ def _normalize_name(name):

def _disassemble_key(name):
# type: (str) -> List[str]
if "." not in name:
error_message = (
"Key does not contain dot separated section and key. "
"Perhaps you wanted to use 'global.{}' instead?"
).format(name)
raise ConfigurationError(error_message)
return name.split(".", 1)


Expand Down
5 changes: 5 additions & 0 deletions tests/functional/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,8 @@ def test_listing_is_correct(self, script):
"""

assert lines == textwrap.dedent(expected).strip().splitlines()

def test_forget_section(self, script):
result = script.pip("config", "set", "isolated", "true",
expect_error=True)
assert "global.isolated" in result.stderr

0 comments on commit 6387867

Please sign in to comment.