From 52f5ef91c27120073e98ce25696049e51f8d62b6 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 11 Aug 2025 07:34:39 +0200 Subject: [PATCH 1/4] [functional tests] Only count the number of python file for the reasonably displayable limit --- pylint/testutils/functional/find_functional_tests.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py index f2e636687b..be5b353ef4 100644 --- a/pylint/testutils/functional/find_functional_tests.py +++ b/pylint/testutils/functional/find_functional_tests.py @@ -11,9 +11,12 @@ from pylint.testutils.functional.test_file import FunctionalTestFile REASONABLY_DISPLAYABLE_VERTICALLY = 49 -"""'Wet finger' number of files that are reasonable to display by an IDE. +"""'Wet finger' number of python files that are reasonable to have in a functional test +directory. 'Wet finger' as in 'in my settings there are precisely this many'. +Initially the total number of file then we started counting only the python files to +avoid moving a lot of files. """ IGNORED_PARENT_DIRS = { @@ -70,7 +73,9 @@ def _get_files_from_dir( ) -> list[Path]: """Return directories and files from a directory and handles violations.""" files_without_leading_underscore = list( - p for p in path.iterdir() if not p.stem.startswith("_") + p + for p in path.iterdir() + if not p.stem.startswith("_") and p.suffix == ".py" ) if len(files_without_leading_underscore) > max_file_per_directory: violations.append((path, len(files_without_leading_underscore))) From 56392fe1b48061dce3cf8e4f490261c6ff8599e4 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 14 Aug 2025 23:15:14 +0200 Subject: [PATCH 2/4] Move used_before_assignment test --- pylint/testutils/functional/find_functional_tests.py | 1 - .../u/{used_02 => used}/used_before_assignment_py313.py | 0 .../u/{used_02 => used}/used_before_assignment_py313.rc | 0 .../u/{used_02 => used}/used_before_assignment_py313.txt | 0 4 files changed, 1 deletion(-) rename tests/functional/u/{used_02 => used}/used_before_assignment_py313.py (100%) rename tests/functional/u/{used_02 => used}/used_before_assignment_py313.rc (100%) rename tests/functional/u/{used_02 => used}/used_before_assignment_py313.txt (100%) diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py index 5ae9612f46..be5b353ef4 100644 --- a/pylint/testutils/functional/find_functional_tests.py +++ b/pylint/testutils/functional/find_functional_tests.py @@ -24,7 +24,6 @@ "ext", "regression", "regression_02", - "used_02", } """Direct parent directories that should be ignored.""" diff --git a/tests/functional/u/used_02/used_before_assignment_py313.py b/tests/functional/u/used/used_before_assignment_py313.py similarity index 100% rename from tests/functional/u/used_02/used_before_assignment_py313.py rename to tests/functional/u/used/used_before_assignment_py313.py diff --git a/tests/functional/u/used_02/used_before_assignment_py313.rc b/tests/functional/u/used/used_before_assignment_py313.rc similarity index 100% rename from tests/functional/u/used_02/used_before_assignment_py313.rc rename to tests/functional/u/used/used_before_assignment_py313.rc diff --git a/tests/functional/u/used_02/used_before_assignment_py313.txt b/tests/functional/u/used/used_before_assignment_py313.txt similarity index 100% rename from tests/functional/u/used_02/used_before_assignment_py313.txt rename to tests/functional/u/used/used_before_assignment_py313.txt From ae1e43351835ca7390aa7916557df52a9b72ee63 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 15 Aug 2025 01:55:04 +0200 Subject: [PATCH 3/4] Fix tests --- pylint/testutils/functional/find_functional_tests.py | 5 ++--- tests/testutils/data/m/max_overflow/max_overflow_3.py | 0 tests/testutils/test_functional_testutils.py | 9 +++++---- 3 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 tests/testutils/data/m/max_overflow/max_overflow_3.py diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py index be5b353ef4..486882c5e8 100644 --- a/pylint/testutils/functional/find_functional_tests.py +++ b/pylint/testutils/functional/find_functional_tests.py @@ -15,7 +15,7 @@ directory. 'Wet finger' as in 'in my settings there are precisely this many'. -Initially the total number of file then we started counting only the python files to +Initially the total number of files then we started counting only the python files to avoid moving a lot of files. """ @@ -75,7 +75,7 @@ def _get_files_from_dir( files_without_leading_underscore = list( p for p in path.iterdir() - if not p.stem.startswith("_") and p.suffix == ".py" + if not (p.stem.startswith("_") or (p.is_file() and p.suffix != ".py")) ) if len(files_without_leading_underscore) > max_file_per_directory: violations.append((path, len(files_without_leading_underscore))) @@ -90,7 +90,6 @@ def walk(path: Path) -> Iterator[Path]: ) for _file_or_dir in parent_dir_files: if _file_or_dir.is_dir(): - _files = _get_files_from_dir(_file_or_dir, violations) yield _file_or_dir.resolve() try: yield from walk(_file_or_dir) diff --git a/tests/testutils/data/m/max_overflow/max_overflow_3.py b/tests/testutils/data/m/max_overflow/max_overflow_3.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/testutils/test_functional_testutils.py b/tests/testutils/test_functional_testutils.py index 0d332f02d9..2b1574e354 100644 --- a/tests/testutils/test_functional_testutils.py +++ b/tests/testutils/test_functional_testutils.py @@ -85,13 +85,14 @@ def test_get_functional_test_files_from_crowded_directory() -> None: get_functional_test_files_from_directory( DATA_DIRECTORY / "m", max_file_per_directory=1 ) - assert exc_info.match("m: 4 when the max is 1") - assert exc_info.match("max_overflow: 3 when the max is 1") + assert exc_info.match("m: 3 when the max is 1") + assert exc_info.match("max_overflow: 2 when the max is 1") + assert len(exc_info.value.args[0].splitlines()) == 3 with pytest.raises(AssertionError) as exc_info: get_functional_test_files_from_directory( - DATA_DIRECTORY / "m", max_file_per_directory=3 + DATA_DIRECTORY / "m", max_file_per_directory=2 ) - assert exc_info.match("m: 4 when the max is 3") + assert exc_info.match("m: 3 when the max is 2") assert "max_overflow" not in str(exc_info.value) From 15a35271bcb01d7cfc2113d3f3790672ae79579a Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Fri, 15 Aug 2025 09:09:13 +0200 Subject: [PATCH 4/4] Update find_functional_tests.py --- pylint/testutils/functional/find_functional_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylint/testutils/functional/find_functional_tests.py b/pylint/testutils/functional/find_functional_tests.py index 486882c5e8..ea58c22138 100644 --- a/pylint/testutils/functional/find_functional_tests.py +++ b/pylint/testutils/functional/find_functional_tests.py @@ -10,7 +10,7 @@ from pylint.testutils.functional.test_file import FunctionalTestFile -REASONABLY_DISPLAYABLE_VERTICALLY = 49 +REASONABLY_DISPLAYABLE_VERTICALLY = 40 """'Wet finger' number of python files that are reasonable to have in a functional test directory.