diff options
| author | Anthony Sottile <asottile@umich.edu> | 2019-12-30 00:20:42 +0000 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2019-12-30 00:20:42 +0000 |
| commit | 20906d43046096c31dfcd9b8bc536dbd21f043ef (patch) | |
| tree | be8cf25e4c6514ed9c71427c44d34bef6d3f23f3 /tests | |
| parent | bb61b3df82a938f7cd1ca32daab4a31e4586b281 (diff) | |
| parent | 738c8490ec56fc364f4229df2c7c9adca8d1d4f2 (diff) | |
| download | flake8-20906d43046096c31dfcd9b8bc536dbd21f043ef.tar.gz | |
Merge branch 'aggregator-config-isolated-fix' into 'master'
aggregator: Forward --config and --isolated options during aggregation
Closes #605
See merge request pycqa/flake8!395
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/integration/test_aggregator.py | 10 | ||||
| -rw-r--r-- | tests/integration/test_main.py | 28 | ||||
| -rw-r--r-- | tests/unit/test_legacy_api.py | 2 |
3 files changed, 33 insertions, 7 deletions
diff --git a/tests/integration/test_aggregator.py b/tests/integration/test_aggregator.py index d2c0133..18ce5e8 100644 --- a/tests/integration/test_aggregator.py +++ b/tests/integration/test_aggregator.py @@ -28,13 +28,12 @@ def optmanager(): def test_aggregate_options_with_config(optmanager): """Verify we aggregate options and config values appropriately.""" - arguments = ['flake8', '--config', CLI_SPECIFIED_CONFIG, '--select', + arguments = ['flake8', '--select', 'E11,E34,E402,W,F', '--exclude', 'tests/*'] config_finder = config.ConfigFileFinder('flake8', []) options, args = aggregator.aggregate_options( - optmanager, config_finder, arguments) + optmanager, config_finder, CLI_SPECIFIED_CONFIG, False, arguments) - assert options.config == CLI_SPECIFIED_CONFIG assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert options.ignore == ['E123', 'W234', 'E111'] assert options.exclude == [os.path.abspath('tests/*')] @@ -42,14 +41,13 @@ def test_aggregate_options_with_config(optmanager): def test_aggregate_options_when_isolated(optmanager): """Verify we aggregate options and config values appropriately.""" - arguments = ['flake8', '--isolated', '--select', 'E11,E34,E402,W,F', + arguments = ['flake8', '--select', 'E11,E34,E402,W,F', '--exclude', 'tests/*'] config_finder = config.ConfigFileFinder('flake8', []) optmanager.extend_default_ignore(['E8']) options, args = aggregator.aggregate_options( - optmanager, config_finder, arguments) + optmanager, config_finder, None, True, arguments) - assert options.isolated is True assert options.select == ['E11', 'E34', 'E402', 'W', 'F'] assert sorted(options.ignore) == [ 'E121', 'E123', 'E126', 'E226', 'E24', 'E704', 'E8', 'W503', 'W504', diff --git a/tests/integration/test_main.py b/tests/integration/test_main.py index f3ace53..42ad76c 100644 --- a/tests/integration/test_main.py +++ b/tests/integration/test_main.py @@ -167,3 +167,31 @@ def test_obtaining_args_from_sys_argv_when_not_explicity_provided(capsys): out, err = capsys.readouterr() assert out.startswith('usage: flake8 [options] file file ...\n') assert err == '' + + +def test_cli_config_option_respected(tmp_path): + """Test --config is used.""" + config = tmp_path / "flake8.ini" + config.write_text(u"""\ +[flake8] +ignore = F401 +""") + + py_file = tmp_path / "t.py" + py_file.write_text(u"import os\n") + + _call_main(["--config", str(config), str(py_file)]) + + +def test_cli_isolated_overrides_config_option(tmp_path): + """Test --isolated overrides --config.""" + config = tmp_path / "flake8.ini" + config.write_text(u"""\ +[flake8] +ignore = F401 +""") + + py_file = tmp_path / "t.py" + py_file.write_text(u"import os\n") + + _call_main(["--isolated", "--config", str(config), str(py_file)], retv=1) diff --git a/tests/unit/test_legacy_api.py b/tests/unit/test_legacy_api.py index 8f6045e..d3b9eb5 100644 --- a/tests/unit/test_legacy_api.py +++ b/tests/unit/test_legacy_api.py @@ -34,7 +34,7 @@ def test_get_style_guide(): 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( - config_finder, []) + config_finder, None, False, []) mockedapp.make_formatter.assert_called_once_with() mockedapp.make_guide.assert_called_once_with() mockedapp.make_file_checker_manager.assert_called_once_with() |
