|
55 | 55 | _extract_session_name, |
56 | 56 | _first_pass, |
57 | 57 | _FirstPassResult, |
| 58 | + _full_scandir_discovery, |
58 | 59 | _infer_model_from_metrics, |
59 | 60 | _insert_session_entry, |
60 | 61 | _read_config_model, |
@@ -522,6 +523,33 @@ def test_two_level_deep_events_not_discovered(self, tmp_path: Path) -> None: |
522 | 523 | assert paths == [valid] |
523 | 524 |
|
524 | 525 |
|
| 526 | +# --------------------------------------------------------------------------- |
| 527 | +# _full_scandir_discovery — OSError on DirEntry.is_dir (issue #896) |
| 528 | +# --------------------------------------------------------------------------- |
| 529 | + |
| 530 | + |
| 531 | +class TestFullScanDirDiscovery: |
| 532 | + """Cover error-handling paths in _full_scandir_discovery.""" |
| 533 | + |
| 534 | + def test_is_dir_oserror_entry_is_skipped(self, tmp_path: Path) -> None: |
| 535 | + """An entry whose is_dir() raises OSError must be silently skipped.""" |
| 536 | + from unittest.mock import MagicMock |
| 537 | + |
| 538 | + bad_entry = MagicMock(spec=os.DirEntry) |
| 539 | + bad_entry.name = "broken-session" |
| 540 | + bad_entry.is_dir.side_effect = OSError("permission denied") |
| 541 | + |
| 542 | + ctx = MagicMock() |
| 543 | + ctx.__enter__ = MagicMock(return_value=iter([bad_entry])) |
| 544 | + ctx.__exit__ = MagicMock(return_value=False) |
| 545 | + |
| 546 | + with patch("os.scandir", return_value=ctx): |
| 547 | + result = _full_scandir_discovery(tmp_path, include_plan=False) |
| 548 | + |
| 549 | + assert result == [] |
| 550 | + bad_entry.is_dir.assert_called_once_with(follow_symlinks=False) |
| 551 | + |
| 552 | + |
525 | 553 | # --------------------------------------------------------------------------- |
526 | 554 | # _discover_with_identity — no stat for absent plan.md (issue #763) |
527 | 555 | # --------------------------------------------------------------------------- |
|
0 commit comments