https://github.com/python/cpython/commit/d11c067246a9f80a3b67f3dbfd2527abc970f0b2
commit: d11c067246a9f80a3b67f3dbfd2527abc970f0b2
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: vstinner <[email protected]>
date: 2026-01-27T10:30:59Z
summary:

[3.14] gh-126014: test_makefile_test_folders: Ignore basically-empty 
directories (GH-140466) (#144269)

gh-126014: test_makefile_test_folders: Ignore basically-empty directories 
(GH-140466)

The code in test_makefile was attempting to ignore any
non-interesting files, but missed some corners:

1. There is never a *file* called `__pycache__`.
2. A directory containing only a `__pycache__` subdirectory should be
   ignored.
3. A directory containing only hidden files should be ignored.

Simplify this all into a couple of filters that let us check for empty
lists.
(cherry picked from commit 17d447e993a0ff9b7d44786ceb2a8f9510638bfa)

Co-authored-by: Stefano Rivera <[email protected]>

files:
M Lib/test/test_tools/test_makefile.py

diff --git a/Lib/test/test_tools/test_makefile.py 
b/Lib/test/test_tools/test_makefile.py
index 4c7588d4d93fc3..31a516067394e1 100644
--- a/Lib/test/test_tools/test_makefile.py
+++ b/Lib/test/test_tools/test_makefile.py
@@ -48,15 +48,18 @@ def test_makefile_test_folders(self):
             if dirname == '__pycache__' or dirname.startswith('.'):
                 dirs.clear()  # do not process subfolders
                 continue
-            # Skip empty dirs:
+
+            # Skip empty dirs (ignoring hidden files and __pycache__):
+            files = [
+                filename for filename in files
+                if not filename.startswith('.')
+            ]
+            dirs = [
+                dirname for dirname in dirs
+                if not dirname.startswith('.') and dirname != "__pycache__"
+            ]
             if not dirs and not files:
                 continue
-            # Skip dirs with hidden-only files:
-            if files and all(
-                filename.startswith('.') or filename == '__pycache__'
-                for filename in files
-            ):
-                continue
 
             relpath = os.path.relpath(dirpath, support.STDLIB_DIR)
             with self.subTest(relpath=relpath):

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to