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>
This commit is contained in:
@@ -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(
|
||||
"""
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user