config: Normalize paths in CLI-specified config relative to config dir

Paths specified in configuration files should be relative to the
directory where the configuration file resides.  Formerly, paths were
normalized relative to the current working directory where `flake8` was
invoked.  The former behavior was not expected, especially for directory
structures with subprojects each having their own configuration.
This commit is contained in:
Eric N. Vander Weele 2020-05-18 17:12:07 -04:00
parent 8be5a7294b
commit 563220b711
2 changed files with 8 additions and 7 deletions

View file

@ -31,15 +31,16 @@ def test_parse_cli_config(optmanager, config_finder):
action='count')
parser = config.MergedConfigParser(optmanager, config_finder)
parsed_config = parser.parse_cli_config(
'tests/fixtures/config_files/cli-specified.ini'
)
config_file = 'tests/fixtures/config_files/cli-specified.ini'
parsed_config = parser.parse_cli_config(config_file)
config_dir = os.path.dirname(config_file)
assert parsed_config == {
'ignore': ['E123', 'W234', 'E111'],
'exclude': [
os.path.abspath('foo/'),
os.path.abspath('bar/'),
os.path.abspath('bogus/'),
os.path.abspath(os.path.join(config_dir, 'foo/')),
os.path.abspath(os.path.join(config_dir, 'bar/')),
os.path.abspath(os.path.join(config_dir, 'bogus/')),
],
'quiet': 1,
}