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

Now that the `ConfigFileFinder` has the `.config_file` 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-12 15:13:41 -08:00
parent 153032f778
commit 77b2506071
4 changed files with 19 additions and 12 deletions

View file

@ -317,14 +317,14 @@ class MergedConfigParser(object):
)
return {}
if cli_config:
if self.config_finder.config_file:
LOG.debug(
"Ignoring user and locally found configuration files. "
'Reading only configuration from "%s" specified via '
"--config by the user",
cli_config,
self.config_finder.config_file,
)
return self.parse_cli_config(cli_config)
return self.parse_cli_config(self.config_finder.config_file)
return self.merge_user_and_local_config()
@ -351,14 +351,14 @@ def get_local_plugins(config_finder, cli_config=None):
)
return local_plugins
if cli_config:
if config_finder.config_file:
LOG.debug(
'Reading local plugins only from "%s" specified via '
"--config by the user",
cli_config,
config_finder.config_file,
)
config = config_finder.cli_config(cli_config)
config_files = [cli_config]
config = config_finder.cli_config(config_finder.config_file)
config_files = [config_finder.config_file]
else:
config, config_files = config_finder.local_configs_with_files()