From 0ff9941b762c0ace2a6bd9bb1985b6149b74e517 Mon Sep 17 00:00:00 2001 From: teknium1 <127238744+teknium1@users.noreply.github.com> Date: Tue, 15 Sep 2026 11:40:20 -0700 Subject: [PATCH] test: one invariant for the importable-resource stub, drop the change-detector Keep a single test on the seam that actually failed: an importable ``resource`` module without ``getrlimit`` (the third-party Windows stub behind #111877/#111879) makes ``_fd_soft_limit`` return None and ``_fd_headroom_ok`` fail open, so session reads proceed. Drop the ``resource_limits`` test from the salvaged PR: ``apply_nofile_soft_limit`` already wraps the rlimit calls in ``except Exception`` on main, so that test was green on base and asserted nothing new. Co-authored-by: KoNit-K <124019182+KoNit-K@users.noreply.github.com> --- tests/hermes_cli/test_resource_limits.py | 7 ------- tests/hermes_state/test_session_db_read_conn_pool.py | 10 ++++++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/hermes_cli/test_resource_limits.py b/tests/hermes_cli/test_resource_limits.py index a4dd998cf4..22018f30a7 100644 --- a/tests/hermes_cli/test_resource_limits.py +++ b/tests/hermes_cli/test_resource_limits.py @@ -100,13 +100,6 @@ def test_unsupported_platform_is_a_safe_noop(monkeypatch): assert resource_limits.apply_nofile_soft_limit({}) is False -def test_windows_resource_stub_without_rlimit_attributes_is_a_safe_noop(monkeypatch): - """Windows can import ``resource`` even when its POSIX API is absent.""" - monkeypatch.setattr(resource_limits, "_resource", object()) - - assert resource_limits.apply_nofile_soft_limit({}) is False - - def test_fresh_process_import_without_posix_resource_is_a_safe_noop(): code = textwrap.dedent( """ diff --git a/tests/hermes_state/test_session_db_read_conn_pool.py b/tests/hermes_state/test_session_db_read_conn_pool.py index 3d8f0352b4..0cafe6b62e 100644 --- a/tests/hermes_state/test_session_db_read_conn_pool.py +++ b/tests/hermes_state/test_session_db_read_conn_pool.py @@ -627,14 +627,16 @@ def test_fd_headroom_guard_fails_open_where_it_cannot_measure(monkeypatch): assert readpool._fd_headroom_ok() is False -def test_fd_soft_limit_ignores_windows_resource_stub(monkeypatch): - """A Windows resource stub has no POSIX RLIMIT attributes.""" +def test_fd_soft_limit_fails_open_for_importable_resource_stub(monkeypatch): + """An importable ``resource`` without ``getrlimit`` (third-party Windows stub, + #111877) must read as "unmeasurable", not abort every session read.""" import sys - from types import SimpleNamespace + import types - monkeypatch.setitem(sys.modules, "resource", SimpleNamespace()) + monkeypatch.setitem(sys.modules, "resource", types.ModuleType("resource")) assert hermes_state_readpool._fd_soft_limit() is None + assert hermes_state_readpool._fd_headroom_ok() is True @pytest.mark.requires_wal