diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-05-28 12:00:47 -0500 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-05-28 12:00:47 -0500 |
| commit | 466ef2e5966d2b36a11dbf205a7bf3835f427d70 (patch) | |
| tree | 6b5c18fff01d86f1ae25a4485edf4ae76a19d32e /tests | |
| parent | 91e07ebcffc0d4ecc472bb0031113f6030f43a20 (diff) | |
| download | flake8-466ef2e5966d2b36a11dbf205a7bf3835f427d70.tar.gz | |
Add example configuration sections to the docs
Add tests to verify our examples do not regress
Diffstat (limited to 'tests')
3 files changed, 65 insertions, 0 deletions
diff --git a/tests/fixtures/config_files/cli-specified-with-inline-comments.ini b/tests/fixtures/config_files/cli-specified-with-inline-comments.ini new file mode 100644 index 0000000..4d57e85 --- /dev/null +++ b/tests/fixtures/config_files/cli-specified-with-inline-comments.ini @@ -0,0 +1,16 @@ +[flake8] +# This is a flake8 config, there are many like it, but this is mine +ignore = + # Disable E123 + E123, + # Disable W234 + W234, + # Also disable E111 + E111 +exclude = + # Exclude foo/ + foo/, + # Exclude bar/ while we're at it + bar/, + # Exclude bogus/ + bogus/ diff --git a/tests/fixtures/config_files/cli-specified-without-inline-comments.ini b/tests/fixtures/config_files/cli-specified-without-inline-comments.ini new file mode 100644 index 0000000..f50ba75 --- /dev/null +++ b/tests/fixtures/config_files/cli-specified-without-inline-comments.ini @@ -0,0 +1,16 @@ +[flake8] +# This is a flake8 config, there are many like it, but this is mine +# Disable E123 +# Disable W234 +# Also disable E111 +ignore = + E123, + W234, + E111 +# Exclude foo/ +# Exclude bar/ while we're at it +# Exclude bogus/ +exclude = + foo/, + bar/, + bogus/ diff --git a/tests/unit/test_merged_config_parser.py b/tests/unit/test_merged_config_parser.py index c64cae6..baaa57a 100644 --- a/tests/unit/test_merged_config_parser.py +++ b/tests/unit/test_merged_config_parser.py @@ -172,3 +172,36 @@ def test_parse_uses_cli_config(ConfigFileManager, optmanager): parser.parse(cli_config='foo.ini') parser.config_finder.cli_config.assert_called_once_with('foo.ini') + + +@pytest.mark.parametrize('config_fixture_path', [ + 'tests/fixtures/config_files/cli-specified.ini', + 'tests/fixtures/config_files/cli-specified-with-inline-comments.ini', + 'tests/fixtures/config_files/cli-specified-without-inline-comments.ini', +]) +def test_parsed_configs_are_equivalent(optmanager, config_fixture_path): + """Verify the each file matches the expected parsed output. + + This is used to ensure our documented behaviour does not regress. + """ + optmanager.add_option('--exclude', parse_from_config=True, + comma_separated_list=True, + normalize_paths=True) + optmanager.add_option('--ignore', parse_from_config=True, + comma_separated_list=True) + parser = config.MergedConfigParser(optmanager) + config_finder = parser.config_finder + + with mock.patch.object(config_finder, 'local_config_files') as localcfs: + localcfs.return_value = [config_fixture_path] + with mock.patch.object(config_finder, + 'user_config_file') as usercf: + usercf.return_value = [] + parsed_config = parser.merge_user_and_local_config() + + assert parsed_config['ignore'] == ['E123', 'W234', 'E111'] + assert parsed_config['exclude'] == [ + os.path.abspath('foo/'), + os.path.abspath('bar/'), + os.path.abspath('bogus/'), + ] |
