Test OSError in _full_scandir_discovery is_dir() (#896)#900
Merged
Conversation
Cover the untested except-OSError branch in _full_scandir_discovery() (parser.py lines 307-310). When DirEntry.is_dir(follow_symlinks=False) raises OSError, the entry is correctly treated as a non-directory and skipped. This test verifies that behavior using a MagicMock DirEntry, mirroring the existing test_stat_failure_on_entry_skipped pattern in test_vscode_parser.py. Closes #896 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds targeted unit coverage for a previously untested defensive branch in session discovery (_full_scandir_discovery) so filesystem edge cases that raise OSError from DirEntry.is_dir(follow_symlinks=False) are validated and won’t regress.
Changes:
- Import
_full_scandir_discoveryintotests/copilot_usage/test_parser.py. - Add a new test ensuring
DirEntry.is_dir()raisingOSErrorresults in the entry being treated as non-directory and skipped (issue #896).
Contributor
There was a problem hiding this comment.
Low-impact test-only addition covering the OSError handling path in _full_scandir_discovery (parser.py lines 307-310). The test properly mocks os.scandir with a DirEntry whose is_dir() raises OSError, verifies the entry is silently skipped, and asserts the call signature. Follows existing test conventions, CI is green. Auto-approving for merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a test for the untested
except OSErrorbranch in_full_scandir_discovery()(parser.pylines 307-310).When
DirEntry.is_dir(follow_symlinks=False)raisesOSError(e.g., broken bind-mount, stale NFS entry, security module denying stat), the entry is correctly treated as a non-directory and skipped. This test verifies that behavior using aMagicMockDirEntrywhoseis_dir()raisesOSError.Follows the same pattern as
test_stat_failure_on_entry_skippedintest_vscode_parser.py.Closes #896