Merge pull request #6491 from DavidBord/fix-5963-fail-elegantly-incorrect-config

fix-5963: fail elegantly
This commit is contained in:
Xavier Fernandez 2019-05-13 22:04:01 +02:00 committed by GitHub
commit 6387867288
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

1
news/5963.bugfix Normal file
View File

@ -0,0 +1 @@
Fail elegantly when trying to set an incorrectly formatted key in config.

View File

@ -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)

View File

@ -57,3 +57,8 @@ class TestBasicLoading(ConfigurationMixin):
"""
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