diff options
| author | Anthony Sottile <asottile@umich.edu> | 2020-01-13 04:27:45 +0000 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2020-01-13 04:27:45 +0000 |
| commit | 44d67e46f5ebe6bc458fe7b18a7b8821e7b2391e (patch) | |
| tree | 578cd3787ffc2495df5eb4c2e3d62b6c9bc72248 /tests | |
| parent | 24c2693979612f1178c444bc991beaed58933a20 (diff) | |
| parent | 1e3bad20dd17981b66121d959b28faf6614edd7e (diff) | |
| download | flake8-44d67e46f5ebe6bc458fe7b18a7b8821e7b2391e.tar.gz | |
Merge branch 'config-finder-config-file' into 'master'
Determine config file override from the ConfigFileFinder object
See merge request pycqa/flake8!401
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration/test_aggregator.py | 9 | ||||
| -rw-r--r-- | tests/unit/test_config_file_finder.py | 17 | ||||
| -rw-r--r-- | tests/unit/test_get_local_plugins.py | 6 | ||||
| -rw-r--r-- | tests/unit/test_legacy_api.py | 4 | ||||
| -rw-r--r-- | tests/unit/test_merged_config_parser.py | 6 |
5 files changed, 33 insertions, 9 deletions
diff --git a/tests/integration/test_aggregator.py b/tests/integration/test_aggregator.py index 672c865..16ed59b 100644 --- a/tests/integration/test_aggregator.py +++ b/tests/integration/test_aggregator.py @@ -30,9 +30,12 @@ def test_aggregate_options_with_config(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', + [], + config_file=CLI_SPECIFIED_CONFIG) options, args = aggregator.aggregate_options( - optmanager, config_finder, CLI_SPECIFIED_CONFIG, arguments) + optmanager, config_finder, arguments) assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert options.ignore == ['E123', 'W234', 'E111'] @@ -47,7 +50,7 @@ def test_aggregate_options_when_isolated(optmanager): 'flake8', [], ignore_config_files=True) optmanager.extend_default_ignore(['E8']) options, args = aggregator.aggregate_options( - optmanager, config_finder, None, arguments) + optmanager, config_finder, arguments) assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert sorted(options.ignore) == [ diff --git a/tests/unit/test_config_file_finder.py b/tests/unit/test_config_file_finder.py index d03118a..93d515a 100644 --- a/tests/unit/test_config_file_finder.py +++ b/tests/unit/test_config_file_finder.py @@ -127,6 +127,23 @@ def test_read_config_catches_decoding_errors(tmpdir): assert parsed == [] +def test_config_file_default_value(): + """Verify the default 'config_file' attribute value.""" + finder = config.ConfigFileFinder('flake8', []) + assert finder.config_file is None + + +def test_setting_config_file_value(): + """Verify the 'config_file' attribute matches constructed value.""" + config_file_value = 'flake8.ini' + finder = config.ConfigFileFinder( + 'flake8', + [], + config_file=config_file_value, + ) + assert finder.config_file == config_file_value + + def test_ignore_config_files_default_value(): """Verify the default 'ignore_config_files' attribute value.""" finder = config.ConfigFileFinder('flake8', []) diff --git a/tests/unit/test_get_local_plugins.py b/tests/unit/test_get_local_plugins.py index 6311677..351be20 100644 --- a/tests/unit/test_get_local_plugins.py +++ b/tests/unit/test_get_local_plugins.py @@ -24,10 +24,12 @@ def test_get_local_plugins_uses_cli_config(): config_finder.cli_config.return_value = config_obj config_finder.ignore_config_files = False config_obj.get.return_value = '' + config_file_value = 'foo.ini' + config_finder.config_file = config_file_value - config.get_local_plugins(config_finder, cli_config='foo.ini') + config.get_local_plugins(config_finder) - config_finder.cli_config.assert_called_once_with('foo.ini') + config_finder.cli_config.assert_called_once_with(config_file_value) def test_get_local_plugins(): diff --git a/tests/unit/test_legacy_api.py b/tests/unit/test_legacy_api.py index 2ec836c..7c7a47e 100644 --- a/tests/unit/test_legacy_api.py +++ b/tests/unit/test_legacy_api.py @@ -31,10 +31,10 @@ def test_get_style_guide(): application.assert_called_once_with() mockedapp.parse_preliminary_options.assert_called_once_with([]) - mockedapp.find_plugins.assert_called_once_with(config_finder, None) + mockedapp.find_plugins.assert_called_once_with(config_finder) mockedapp.register_plugin_options.assert_called_once_with() mockedapp.parse_configuration_and_cli.assert_called_once_with( - config_finder, None, []) + 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() diff --git a/tests/unit/test_merged_config_parser.py b/tests/unit/test_merged_config_parser.py index f2d70d9..6689776 100644 --- a/tests/unit/test_merged_config_parser.py +++ b/tests/unit/test_merged_config_parser.py @@ -155,12 +155,14 @@ def test_parse_isolates_config(optmanager): def test_parse_uses_cli_config(optmanager): """Verify behaviour of the parse method with a specified config.""" + config_file_value = 'foo.ini' config_finder = mock.MagicMock() + config_finder.config_file = config_file_value config_finder.ignore_config_files = False parser = config.MergedConfigParser(optmanager, config_finder) - parser.parse(cli_config='foo.ini') - config_finder.cli_config.assert_called_once_with('foo.ini') + parser.parse() + config_finder.cli_config.assert_called_once_with(config_file_value) @pytest.mark.parametrize('config_fixture_path', [ |
