From ce2652a3b396909ba3de457d7588c643f34e8888 Mon Sep 17 00:00:00 2001 From: Miguel Jacq Date: Sun, 21 Jun 2026 16:15:33 +1000 Subject: [PATCH] Handle gracefully debian stuff when testing on rhel-like --- enroll/debian.py | 7 ++++++- tests/test_debian.py | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/enroll/debian.py b/enroll/debian.py index 6d0ca06..14becad 100644 --- a/enroll/debian.py +++ b/enroll/debian.py @@ -186,7 +186,12 @@ def parse_status_conffiles( if m: out[pkg] = m - with open(status_path, "r", encoding="utf-8", errors="replace") as f: + try: + f = open(status_path, "r", encoding="utf-8", errors="replace") + except OSError: + return out + + with f: for line in f: if line.strip() == "": if cur: diff --git a/tests/test_debian.py b/tests/test_debian.py index 64fe420..40e94f5 100644 --- a/tests/test_debian.py +++ b/tests/test_debian.py @@ -280,6 +280,12 @@ def test_build_dpkg_etc_index_skips_non_etc_paths(tmp_path: Path): assert "foo" not in topdir_to_pkgs +def test_parse_status_conffiles_handles_missing_status(tmp_path: Path): + import enroll.debian as d + + assert d.parse_status_conffiles(str(tmp_path / "missing-status")) == {} + + def test_parse_status_conffiles_handles_empty_status(tmp_path: Path): import enroll.debian as d