Skip to content

Commit c4c9214

Browse files
committed
gh-126014: test_makefile_test_folders: Ignore basically-empty directories
The code in test_makefile was attempting to ignore any 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.
1 parent 237dca5 commit c4c9214

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Lib/test/test_tools/test_makefile.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,18 @@ def test_makefile_test_folders(self):
4848
if dirname == '__pycache__' or dirname.startswith('.'):
4949
dirs.clear() # do not process subfolders
5050
continue
51-
# Skip empty dirs:
51+
52+
# Skip empty dirs (ignoring hidden files and __pycache__):
53+
files = [
54+
filename for filename in files
55+
if not filename.startswith('.')
56+
]
57+
dirs = [
58+
dirname for dirname in dirs
59+
if not dirname.startswith('.') and dirname != "__pycache__"
60+
]
5261
if not dirs and not files:
5362
continue
54-
# Skip dirs with hidden-only files:
55-
if files and all(
56-
filename.startswith('.') or filename == '__pycache__'
57-
for filename in files
58-
):
59-
continue
6063

6164
relpath = os.path.relpath(dirpath, support.STDLIB_DIR)
6265
with self.subTest(relpath=relpath):

0 commit comments

Comments
 (0)