application: Remove configuration finder state

This change removes the `.config_finder` object from the `Application`.
Since the configuration finder is only needed during initialization, we
constrain the finder to be returned and passed to other methods
necessary for initialization.
This commit is contained in:
Eric N. Vander Weele 2019-11-09 09:55:01 +08:00
parent c9209507a8
commit 594c16abb4
3 changed files with 26 additions and 16 deletions

View file

@ -6,6 +6,7 @@ import pytest
from flake8.api import legacy as api
from flake8.formatting import base as formatter
from flake8.options.config import ConfigFileFinder
def test_get_style_guide():
@ -20,6 +21,8 @@ def test_get_style_guide():
mockedapp = mock.Mock()
mockedapp.parse_preliminary_options.return_value = (prelim_opts, [])
mockedapp.program = 'flake8'
config_finder = ConfigFileFinder(mockedapp.program, [])
mockedapp.make_config_finder.return_value = config_finder
with mock.patch('flake8.main.application.Application') as application:
application.return_value = mockedapp
style_guide = api.get_style_guide()
@ -27,9 +30,10 @@ def test_get_style_guide():
application.assert_called_once_with()
mockedapp.parse_preliminary_options.assert_called_once_with([])
mockedapp.make_config_finder.assert_called_once_with(mockedapp.program, [])
mockedapp.find_plugins.assert_called_once_with(None, False)
mockedapp.find_plugins.assert_called_once_with(config_finder, None, False)
mockedapp.register_plugin_options.assert_called_once_with()
mockedapp.parse_configuration_and_cli.assert_called_once_with([])
mockedapp.parse_configuration_and_cli.assert_called_once_with(
config_finder, [])
mockedapp.make_formatter.assert_called_once_with()
mockedapp.make_guide.assert_called_once_with()
mockedapp.make_file_checker_manager.assert_called_once_with()