mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-31 03:06:53 +00:00
Fix bugs found while writing parse_cli_config test
This commit is contained in:
parent
03fd22c230
commit
a8576aff12
3 changed files with 25 additions and 3 deletions
|
|
@ -186,9 +186,11 @@ class MergedConfigParser(object):
|
|||
value = method(self.program_name, option_name)
|
||||
LOG.debug('Option "%s" returned value: %r', option_name, value)
|
||||
|
||||
final_value = self._normalize_value(value)
|
||||
final_value = self._normalize_value(option, value)
|
||||
config_dict[option_name] = final_value
|
||||
|
||||
return config_dict
|
||||
|
||||
def is_configured_by(self, config):
|
||||
"""Check if the specified config parser has an appropriate section."""
|
||||
return config.has_section(self.program_name)
|
||||
|
|
|
|||
|
|
@ -104,7 +104,8 @@ class Option(object):
|
|||
'dest={dest}, type={type}, callback={callback}, help={help},'
|
||||
' callback={callback}, callback_args={callback_args}, '
|
||||
'callback_kwargs={callback_kwargs}, metavar={metavar})'
|
||||
).format(*self.option_args, **self.option_kwargs)
|
||||
).format(self.short_option_name, self.long_option_name,
|
||||
**self.option_kwargs)
|
||||
|
||||
def _make_dest(self, dest):
|
||||
if dest:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
"""Unit tests for flake8.options.config.MergedConfigParser."""
|
||||
import os
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
|
|
@ -38,4 +40,21 @@ def test_creates_its_own_config_file_finder(args, extra_config_files,
|
|||
|
||||
|
||||
def test_parse_cli_config(optmanager):
|
||||
pass
|
||||
optmanager.add_option('--exclude', parse_from_config=True,
|
||||
comma_separated_list=True,
|
||||
normalize_paths=True)
|
||||
optmanager.add_option('--ignore', parse_from_config=True,
|
||||
comma_separated_list=True)
|
||||
parser = config.MergedConfigParser(optmanager)
|
||||
|
||||
parsed_config = parser.parse_cli_config(
|
||||
'tests/fixtures/config_files/cli-specified.ini'
|
||||
)
|
||||
assert parsed_config == {
|
||||
'ignore': ['E123', 'W234', 'E111'],
|
||||
'exclude': [
|
||||
os.path.abspath('foo/'),
|
||||
os.path.abspath('bar/'),
|
||||
os.path.abspath('bogus/'),
|
||||
]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue