Skip to content

Commit 1b6cccf

Browse files
[functional tests] Only count python files for the reasonably displayable limit (#10490)
Co-authored-by: Marc Mueller <[email protected]>
1 parent 7963db4 commit 1b6cccf

File tree

6 files changed

+13
-9
lines changed

6 files changed

+13
-9
lines changed

pylint/testutils/functional/find_functional_tests.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,20 @@
1010

1111
from pylint.testutils.functional.test_file import FunctionalTestFile
1212

13-
REASONABLY_DISPLAYABLE_VERTICALLY = 49
14-
"""'Wet finger' number of files that are reasonable to display by an IDE.
13+
REASONABLY_DISPLAYABLE_VERTICALLY = 40
14+
"""'Wet finger' number of python files that are reasonable to have in a functional test
15+
directory.
1516
1617
'Wet finger' as in 'in my settings there are precisely this many'.
18+
Initially the total number of files then we started counting only the python files to
19+
avoid moving a lot of files.
1720
"""
1821

1922
IGNORED_PARENT_DIRS = {
2023
"deprecated_relative_import",
2124
"ext",
2225
"regression",
2326
"regression_02",
24-
"used_02",
2527
}
2628
"""Direct parent directories that should be ignored."""
2729

@@ -71,7 +73,9 @@ def _get_files_from_dir(
7173
) -> list[Path]:
7274
"""Return directories and files from a directory and handles violations."""
7375
files_without_leading_underscore = list(
74-
p for p in path.iterdir() if not p.stem.startswith("_")
76+
p
77+
for p in path.iterdir()
78+
if not (p.stem.startswith("_") or (p.is_file() and p.suffix != ".py"))
7579
)
7680
if len(files_without_leading_underscore) > max_file_per_directory:
7781
violations.append((path, len(files_without_leading_underscore)))
@@ -86,7 +90,6 @@ def walk(path: Path) -> Iterator[Path]:
8690
)
8791
for _file_or_dir in parent_dir_files:
8892
if _file_or_dir.is_dir():
89-
_files = _get_files_from_dir(_file_or_dir, violations)
9093
yield _file_or_dir.resolve()
9194
try:
9295
yield from walk(_file_or_dir)

tests/testutils/data/m/max_overflow/max_overflow_3.py

Whitespace-only changes.

tests/testutils/test_functional_testutils.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ def test_get_functional_test_files_from_crowded_directory() -> None:
8585
get_functional_test_files_from_directory(
8686
DATA_DIRECTORY / "m", max_file_per_directory=1
8787
)
88-
assert exc_info.match("m: 4 when the max is 1")
89-
assert exc_info.match("max_overflow: 3 when the max is 1")
88+
assert exc_info.match("m: 3 when the max is 1")
89+
assert exc_info.match("max_overflow: 2 when the max is 1")
90+
assert len(exc_info.value.args[0].splitlines()) == 3
9091
with pytest.raises(AssertionError) as exc_info:
9192
get_functional_test_files_from_directory(
92-
DATA_DIRECTORY / "m", max_file_per_directory=3
93+
DATA_DIRECTORY / "m", max_file_per_directory=2
9394
)
94-
assert exc_info.match("m: 4 when the max is 3")
95+
assert exc_info.match("m: 3 when the max is 2")
9596
assert "max_overflow" not in str(exc_info.value)
9697

9798

0 commit comments

Comments
 (0)