Raise exception if append-config does not exist

This commit is contained in:
lt94 2022-11-06 19:29:05 +08:00 committed by Anthony Sottile
parent ad1006e8cb
commit 314b9f5161
2 changed files with 9 additions and 1 deletions

View file

@ -87,7 +87,10 @@ def load_config(
# TODO: remove this and replace it with configuration modifying plugins
# read the additional configs afterwards
for filename in extra:
cfg.read(filename, encoding="UTF-8")
if not cfg.read(filename, encoding="UTF-8"):
raise exceptions.ExecutionError(
f"The specified config file does not exist: {filename}"
)
return cfg, cfg_dir

View file

@ -222,6 +222,11 @@ def test_load_config_missing_file_raises_exception(capsys):
config.load_config("foo.cfg", [])
def test_load_config_missing_append_config_raise_exception():
with pytest.raises(exceptions.ExecutionError):
config.load_config(None, ["dont_exist_config.cfg"], isolated=False)
def test_invalid_ignore_codes_raise_error(tmpdir, opt_manager):
tmpdir.join("setup.cfg").write("[flake8]\nignore = E203, //comment")
with tmpdir.as_cwd():