mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-06 21:16:54 +00:00
Add tests for generate_possible_local_config_files
Fix a bug found via testing where we traverse all the way to the root directory looking for config files.
This commit is contained in:
parent
dd46f02b58
commit
949d3e48fe
2 changed files with 27 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ import os
|
|||
import sys
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
from flake8.options import config
|
||||
|
||||
|
|
@ -21,8 +22,30 @@ def test_windows_detection():
|
|||
|
||||
|
||||
def test_cli_config():
|
||||
"""Verify opening and reading the file specified via the cli."""
|
||||
cli_filepath = 'tests/fixtures/config_files/cli-specified.ini'
|
||||
finder = config.ConfigFileFinder('flake8', None, [])
|
||||
|
||||
parsed_config = finder.cli_config(cli_filepath)
|
||||
assert parsed_config.has_section('flake8')
|
||||
|
||||
|
||||
@pytest.mark.parametrize('args,expected', [
|
||||
([], # No arguments
|
||||
[os.path.abspath('setup.cfg'),
|
||||
os.path.abspath('tox.ini'),
|
||||
os.path.abspath('.flake8')]),
|
||||
(['flake8/options', 'flake8/'], # Common prefix of "flake8/"
|
||||
[os.path.abspath('flake8/setup.cfg'),
|
||||
os.path.abspath('flake8/tox.ini'),
|
||||
os.path.abspath('flake8/.flake8'),
|
||||
os.path.abspath('setup.cfg'),
|
||||
os.path.abspath('tox.ini'),
|
||||
os.path.abspath('.flake8')]),
|
||||
])
|
||||
def test_generate_possible_local_config_files(args, expected):
|
||||
"""Verify generation of all possible config paths."""
|
||||
finder = config.ConfigFileFinder('flake8', args, [])
|
||||
|
||||
assert (list(finder.generate_possible_local_config_files()) ==
|
||||
expected)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue