mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-07 05:26:53 +00:00
Ensures help text defaults not clobbered by config
- Matches help text default format with invocation docs - Resolves #1666
This commit is contained in:
parent
e249dc47df
commit
ec7e7c8a27
2 changed files with 62 additions and 4 deletions
|
|
@ -1,12 +1,14 @@
|
|||
"""Integration tests for the main entrypoint of flake8."""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from unittest import mock
|
||||
|
||||
import pytest
|
||||
|
||||
from flake8 import utils
|
||||
from flake8.defaults import EXCLUDE
|
||||
from flake8.main import cli
|
||||
from flake8.options import config
|
||||
|
||||
|
|
@ -149,6 +151,33 @@ def test_extend_exclude(tmpdir, capsys):
|
|||
assert err == ""
|
||||
|
||||
|
||||
def test_config_value_does_not_clobber_default_help_text(tmpdir, capsys):
|
||||
"""Test a config value does not clobber the default help text output."""
|
||||
setup_cfg = """\
|
||||
[flake8]
|
||||
exclude = 1,2
|
||||
"""
|
||||
expected = ",".join(EXCLUDE)
|
||||
|
||||
default_pattern = re.compile(r"\(Default:(.*?)\)")
|
||||
whitespace_pattern = re.compile(r"\s+")
|
||||
|
||||
with tmpdir.as_cwd():
|
||||
tmpdir.join("setup.cfg").write(setup_cfg)
|
||||
with pytest.raises(SystemExit):
|
||||
cli.main(["-h"])
|
||||
|
||||
out, err = capsys.readouterr()
|
||||
|
||||
for section in out.split("--"):
|
||||
if section.startswith("exclude patterns"):
|
||||
section = re.sub(whitespace_pattern, "", section)
|
||||
default_groups = re.search(default_pattern, section)
|
||||
assert default_groups is not None
|
||||
default = default_groups.group(1)
|
||||
assert default == expected
|
||||
|
||||
|
||||
def test_malformed_per_file_ignores_error(tmpdir, capsys):
|
||||
"""Test the error message for malformed `per-file-ignores`."""
|
||||
setup_cfg = """\
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue