Skip to content

Commit

Permalink
[testutil] Display all the crowded functional test dir at once
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Sassoulas committed Mar 23, 2023
1 parent a0b1ab0 commit e7d092d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pylint/testutils/functional/find_functional_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from pylint.testutils.functional.test_file import FunctionalTestFile

REASONABLY_DISPLAYABLE_VERTICALLY = 48
REASONABLY_DISPLAYABLE_VERTICALLY = 49
"""'Wet finger' number of files that are reasonable to display by an IDE."""
SHOULD_BE_IN_THE_SAME_DIRECTORY = 5
"""'Wet finger' as in 'in my settings there are precisely this many'."""
Expand Down Expand Up @@ -62,17 +62,21 @@ def _check_functional_tests_structure(directory: Path) -> None:
dirs: set[Path] = set()

def walk(path: Path) -> Iterator[Path]:
violations: list[tuple[Path, int]] = []
for _file_or_dir in path.iterdir():
if _file_or_dir.is_dir():
_files = list(_file_or_dir.iterdir())
assert len(_files) <= REASONABLY_DISPLAYABLE_VERTICALLY, (
f"{_file_or_dir} contains too many functional tests files "
+ f"({len(_files)} > {REASONABLY_DISPLAYABLE_VERTICALLY})."
)
if len(_files) > REASONABLY_DISPLAYABLE_VERTICALLY:
violations.append((_file_or_dir, len(_files)))
yield _file_or_dir
yield from walk(_file_or_dir)
else:
yield _file_or_dir.resolve()
if violations:
msg = "The following directory contains too many functional tests files:\n"
for offending_file, number in violations:
msg += f"- {offending_file}: ({number}) > {REASONABLY_DISPLAYABLE_VERTICALLY}\n"
raise AssertionError(msg)

# Collect all sub-directories and files in directory
for file_or_dir in walk(directory):
Expand Down

0 comments on commit e7d092d

Please sign in to comment.