mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-12 07:44:16 +00:00
Merge branch 'config-remove-parent-tail-state' into 'master'
config: Remove ConfigFileFinder 'parent' and 'tail' attributes See merge request pycqa/flake8!400
This commit is contained in:
commit
bde8f156a5
2 changed files with 9 additions and 11 deletions
|
|
@ -51,8 +51,6 @@ class ConfigFileFinder(object):
|
||||||
|
|
||||||
self.local_directory = os.path.abspath(os.curdir)
|
self.local_directory = os.path.abspath(os.curdir)
|
||||||
|
|
||||||
self.parent = self.tail = os.getcwd()
|
|
||||||
|
|
||||||
# caches to avoid double-reading config files
|
# caches to avoid double-reading config files
|
||||||
self._local_configs = None
|
self._local_configs = None
|
||||||
self._local_found_files = [] # type: List[str]
|
self._local_found_files = [] # type: List[str]
|
||||||
|
|
@ -96,8 +94,7 @@ class ConfigFileFinder(object):
|
||||||
|
|
||||||
def generate_possible_local_files(self):
|
def generate_possible_local_files(self):
|
||||||
"""Find and generate all local config files."""
|
"""Find and generate all local config files."""
|
||||||
tail = self.tail
|
parent = tail = os.getcwd()
|
||||||
parent = self.parent
|
|
||||||
found_config_files = False
|
found_config_files = False
|
||||||
while tail and not found_config_files:
|
while tail and not found_config_files:
|
||||||
for project_filename in self.project_filenames:
|
for project_filename in self.project_filenames:
|
||||||
|
|
|
||||||
|
|
@ -48,24 +48,25 @@ def test_cli_config_double_read():
|
||||||
|
|
||||||
@pytest.mark.parametrize('cwd,expected', [
|
@pytest.mark.parametrize('cwd,expected', [
|
||||||
# Root directory of project
|
# Root directory of project
|
||||||
('.',
|
(os.path.abspath('.'),
|
||||||
[os.path.abspath('setup.cfg'),
|
[os.path.abspath('setup.cfg'),
|
||||||
os.path.abspath('tox.ini')]),
|
os.path.abspath('tox.ini')]),
|
||||||
# Subdirectory of project directory
|
# Subdirectory of project directory
|
||||||
('src',
|
(os.path.abspath('src'),
|
||||||
[os.path.abspath('setup.cfg'),
|
[os.path.abspath('setup.cfg'),
|
||||||
os.path.abspath('tox.ini')]),
|
os.path.abspath('tox.ini')]),
|
||||||
# Outside of project directory
|
# Outside of project directory
|
||||||
('/',
|
(os.path.abspath('/'),
|
||||||
[]),
|
[]),
|
||||||
])
|
])
|
||||||
def test_generate_possible_local_files(cwd, expected):
|
def test_generate_possible_local_files(cwd, expected):
|
||||||
"""Verify generation of all possible config paths."""
|
"""Verify generation of all possible config paths."""
|
||||||
with mock.patch.object(os, 'getcwd', return_value=cwd):
|
finder = config.ConfigFileFinder('flake8', [])
|
||||||
finder = config.ConfigFileFinder('flake8', [])
|
|
||||||
|
|
||||||
assert (list(finder.generate_possible_local_files())
|
with mock.patch.object(os, 'getcwd', return_value=cwd):
|
||||||
== expected)
|
config_files = list(finder.generate_possible_local_files())
|
||||||
|
|
||||||
|
assert config_files == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('extra_config_files,expected', [
|
@pytest.mark.parametrize('extra_config_files,expected', [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue