diff --git a/tests/test_io/test_io_core.py b/tests/test_io/test_io_core.py index 4a81afd87..96ae60ff9 100644 --- a/tests/test_io/test_io_core.py +++ b/tests/test_io/test_io_core.py @@ -18,6 +18,7 @@ import dascore as dc from dascore.config import config_context from dascore.exceptions import ( + DependencyError, InvalidFiberIOError, MissingOptionalDependencyError, MissingPatchError, @@ -199,6 +200,25 @@ def get_format(self, resource: Path, **kwargs) -> tuple[str, str] | Literal[Fals return False +class _DependencyErrorFormatter(FiberIO): + """A formatter whose scan path hits a dependency/compatibility problem.""" + + name = "_dependency_error_formatter" + version = "1" + + def scan(self, resource: Path, **kwargs): + """Raise a stable dependency error for scan coverage tests.""" + msg = "simulated stack incompatibility while scanning" + raise DependencyError(msg) + + def get_format(self, resource: Path, **kwargs) -> tuple[str, str] | Literal[False]: + """Only accept the explicit dependency-error test resource.""" + path = Path(resource) + if path.suffix == ".dep" and path.name == "dependency_error.dep": + return self.name, self.version + return False + + class TestGetExactCoord: """Tests for constructing exact coordinates during scans.""" @@ -957,6 +977,26 @@ def test_scan_missing_optional_dependency_warns_with_other_outputs(self, tmp_pat assert len(out) == 1 assert out[0].source_format == _ReadOnlySummaryFormatter.name + def test_scan_dependency_error_warns_and_skips(self, tmp_path): + """ + A scan-time dependency/compatibility problem warns and keeps scanning. + + Scan is best-effort across many resources, so such problems must + surface as warnings on the affected file rather than aborting the + whole scan. (The DASVader legacy file used to exercise this branch, + but whether it does depends on the installed HDF5 stack.) + """ + dep_path = tmp_path / "dependency_error.dep" + dep_path.write_text("placeholder") + readable_path = tmp_path / "fallback_scan.h5" + readable_path.write_text("placeholder") + + with pytest.warns(UserWarning, match="simulated stack incompatibility"): + out = dc.scan([dep_path, readable_path]) + + assert len(out) == 1 + assert out[0].source_format == _ReadOnlySummaryFormatter.name + def test_local_upath_file_interfaces(self, terra15_v6_path): """Ensure core file IO accepts local UPath inputs.""" path = UPath(terra15_v6_path)