config: Switch code paths to use 'ConfigFileFinder.ignore_config_files'

Now that the `ConfigFileFinder` has the `.ignore_config_files`
attribute, switch the relevant code paths to utilize this public
attribute.

Tests have been updated to either construct `ConfigFileFinder` or mock
the object appropriately.
This commit is contained in:
Eric N. Vander Weele 2020-01-07 13:03:34 -05:00
parent a5c17c1a19
commit 3d546d448a
4 changed files with 6 additions and 3 deletions

View file

@ -307,7 +307,7 @@ class MergedConfigParser(object):
:rtype:
dict
"""
if isolated:
if self.config_finder.ignore_config_files:
LOG.debug(
"Refusing to parse configuration files due to user-"
"requested isolation"
@ -344,7 +344,7 @@ def get_local_plugins(config_finder, cli_config=None, isolated=False):
flake8.options.config.LocalPlugins
"""
local_plugins = LocalPlugins(extension=[], report=[], paths=[])
if isolated:
if config_finder.ignore_config_files:
LOG.debug(
"Refusing to look for local plugins in configuration"
"files due to user-requested isolation"

View file

@ -43,7 +43,8 @@ def test_aggregate_options_when_isolated(optmanager):
"""Verify we aggregate options and config values appropriately."""
arguments = ['flake8', '--select', 'E11,E34,E402,W,F',
'--exclude', 'tests/*']
config_finder = config.ConfigFileFinder('flake8', [])
config_finder = config.ConfigFileFinder(
'flake8', [], ignore_config_files=True)
optmanager.extend_default_ignore(['E8'])
options, args = aggregator.aggregate_options(
optmanager, config_finder, None, True, arguments)

View file

@ -21,6 +21,7 @@ def test_get_local_plugins_uses_cli_config():
config_obj = mock.Mock()
config_finder = mock.MagicMock()
config_finder.cli_config.return_value = config_obj
config_finder.ignore_config_files = False
config_obj.get.return_value = ''
config.get_local_plugins(config_finder, cli_config='foo.ini')

View file

@ -155,6 +155,7 @@ def test_parse_isolates_config(optmanager):
def test_parse_uses_cli_config(optmanager):
"""Verify behaviour of the parse method with a specified config."""
config_finder = mock.MagicMock()
config_finder.ignore_config_files = False
parser = config.MergedConfigParser(optmanager, config_finder)
parser.parse(cli_config='foo.ini')