Skip to content
Snippets Groups Projects
Commit 7654dde4 authored by Amir Rachum's avatar Amir Rachum Committed by GitHub
Browse files

Merge pull request #280 from FarmerSez/config-file-warning

Config file warning
parents d9d46f67 17fbe411
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -25,6 +25,8 @@ Bug Fixes
* Fixed an issue where if a first word in a docstring had Unicode characters
and the docstring was not a unicode string, an exception would be raised
(#258, #264).
* Configuration files that were specified by CLI and don't contain a valid
section name will now issue a warning to ``stderr`` (#276, #280).
 
 
2.0.0 - April 18th, 2017
Loading
Loading
Loading
Loading
@@ -256,10 +256,17 @@ class ConfigurationParser(object):
raise IllegalConfiguration('Configuration file {!r} specified '
'via --config was not found.'
.format(self._run_conf.config))
if None in self._cache:
return self._cache[None]
options, _ = self._read_configuration_file(self._run_conf.config)
config = self._create_check_config(options)
if options is None:
log.warning('Configuration file does not contain a '
'pydocstyle section. Using default configuration.')
config = self._create_check_config(self._options)
else:
config = self._create_check_config(options)
 
# Make the CLI always win
final_config = {}
Loading
Loading
Loading
Loading
@@ -251,6 +251,32 @@ def test_config_file(env):
assert 'D103' not in err
 
 
def test_sectionless_config_file(env):
"""Test that config files without a valid section name issue a warning."""
with env.open('config.ini', 'wt') as conf:
conf.write('[pdcstl]')
config_path = conf.name
_, err, code = env.invoke('--config={}'.format(config_path))
assert code == 0
assert 'Configuration file does not contain a pydocstyle section' in err
with env.open('example.py', 'wt') as example:
example.write(textwrap.dedent("""\
def foo():
pass
"""))
with env.open('tox.ini', 'wt') as conf:
conf.write('[pdcstl]\n')
conf.write('ignore = D100')
out, err, code = env.invoke()
assert code == 1
assert 'D100' in out
assert 'file does not contain a pydocstyle section' not in err
def test_config_path(env):
"""Test that options are correctly loaded from a specific config file.
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment