mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 05:26:53 +00:00
Add support for reading config from pyproject.toml
This commit is contained in:
parent
1d30b79ce1
commit
c609b69914
7 changed files with 72 additions and 5 deletions
|
|
@ -10,10 +10,19 @@ from flake8.options import config
|
|||
CLI_SPECIFIED_FILEPATH = "tests/fixtures/config_files/cli-specified.ini"
|
||||
BROKEN_CONFIG_PATH = "tests/fixtures/config_files/broken.ini"
|
||||
|
||||
CLI_SPECIFIED_PYPROJECT_CONFIG_PATH = "tests/fixtures/config_files/cli-specified-pyproject.toml" # noqa: E501
|
||||
BROKEN_PYPROJECT_CONFIG_PATH = "tests/fixtures/config_files/broken-pyproject.toml" # noqa: E501
|
||||
|
||||
def test_cli_config():
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"cli_filepath",
|
||||
[
|
||||
CLI_SPECIFIED_FILEPATH,
|
||||
CLI_SPECIFIED_PYPROJECT_CONFIG_PATH,
|
||||
],
|
||||
)
|
||||
def test_cli_config(cli_filepath):
|
||||
"""Verify opening and reading the file specified via the cli."""
|
||||
cli_filepath = CLI_SPECIFIED_FILEPATH
|
||||
finder = config.ConfigFileFinder("flake8")
|
||||
|
||||
parsed_config = finder.cli_config(cli_filepath)
|
||||
|
|
@ -91,13 +100,19 @@ def test_local_configs():
|
|||
"files",
|
||||
[
|
||||
[BROKEN_CONFIG_PATH],
|
||||
[CLI_SPECIFIED_FILEPATH, BROKEN_CONFIG_PATH],
|
||||
[BROKEN_PYPROJECT_CONFIG_PATH],
|
||||
[
|
||||
CLI_SPECIFIED_FILEPATH,
|
||||
BROKEN_CONFIG_PATH,
|
||||
BROKEN_PYPROJECT_CONFIG_PATH,
|
||||
],
|
||||
],
|
||||
)
|
||||
def test_read_config_catches_broken_config_files(files):
|
||||
"""Verify that we do not allow the exception to bubble up."""
|
||||
_, parsed = config.ConfigFileFinder._read_config(*files)
|
||||
assert BROKEN_CONFIG_PATH not in parsed
|
||||
assert BROKEN_PYPROJECT_CONFIG_PATH not in parsed
|
||||
|
||||
|
||||
def test_read_config_catches_decoding_errors(tmpdir):
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ def test_parse_cli_config(optmanager, config_finder):
|
|||
[
|
||||
("tests/fixtures/config_files/cli-specified.ini", True),
|
||||
("tests/fixtures/config_files/no-flake8-section.ini", False),
|
||||
("tests/fixtures/config_files/no-flake8-section-pyproject.toml", False), # noqa: E501
|
||||
],
|
||||
)
|
||||
def test_is_configured_by(
|
||||
|
|
@ -188,6 +189,7 @@ def test_parse_uses_cli_config(optmanager):
|
|||
"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", # noqa: E501
|
||||
"tests/fixtures/config_files/cli-specified-pyproject.toml",
|
||||
],
|
||||
)
|
||||
def test_parsed_configs_are_equivalent(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue