add check for a missing specified config file

This commit is contained in:
Ruairidh MacLeod 2021-12-24 01:36:41 +00:00
parent d478d92299
commit d948169292
2 changed files with 6 additions and 2 deletions

View file

@ -8,6 +8,7 @@ from typing import List
from typing import Optional
from typing import Tuple
from flake8 import exceptions
from flake8.options.manager import OptionManager
LOG = logging.getLogger(__name__)
@ -60,7 +61,10 @@ def load_config(
cfg = configparser.RawConfigParser()
if config is not None:
cfg.read(config)
if not cfg.read(config):
raise exceptions.ExecutionError(
f"The specified config file does not exist: {config}"
)
cfg_dir = os.path.dirname(config)
else:
cfg_dir = pwd

View file

@ -394,7 +394,7 @@ def test_config_file_not_found(tmpdir, capsys):
expected = """\
There was a critical error during execution of Flake8:
The specified config file does not exist
The specified config file does not exist: missing.cfg
"""
with tmpdir.as_cwd():