Skip to content

Fix: get_log_files() in xprocess/pytest_xprocess.py filters directory... - #165

Open
M001N wants to merge 1 commit into
pytest-dev:masterfrom
M001N:oss-engine/7c619bc4-cdf3062a
Open

Fix: get_log_files() in xprocess/pytest_xprocess.py filters directory...#165
M001N wants to merge 1 commit into
pytest-dev:masterfrom
M001N:oss-engine/7c619bc4-cdf3062a

Conversation

@M001N

@M001N M001N commented Aug 17, 2026

Copy link
Copy Markdown

Summary

Added an os.path.isfile() check alongside the existing suffix filter: if f.endswith("log") and os.path.isfile(os.path.join(proc_dir, f)), so directories are excluded from the returned log-file list.

Problem

pytest-dev/pytest-xprocess issue reference: #135

Root Cause

get_log_files() in xprocess/pytest_xprocess.py filters directory entries with if f.endswith("log") only, never checking whether the entry is a regular file. A subdirectory whose name ends in 'log' (e.g. one named exactly 'log') passes this filter and is returned alongside real log files.

Testing

PASS - new regression test passes; full scoped suite (excluding the 3 known-flaky subprocess-based files) shows 25 passed, 3 skipped (skips are pre-existing, platform-gated SIGTERM test on win32), 0 failed.

Related Issue

#135

…t-dev#135)

get_log_files() filtered candidate log files by name suffix only,
without checking whether the entry was actually a file. A process
working directory containing a subdirectory literally named 'log'
(or otherwise ending in 'log') would be included in the returned
list, causing callers to crash with IsADirectoryError when they
tried to open() it.

Add an os.path.isfile() check alongside the existing suffix filter.
Add a self-contained regression test using tmp_path that reproduces
the exact scenario from the issue.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant