File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,6 +43,8 @@ def __init__(
4343 critical_threshold : float = _DEFAULT_CRITICAL_THRESHOLD ,
4444 check_interval : int = _DEFAULT_CHECK_INTERVAL ,
4545 ) -> None :
46+ if check_interval < 1 :
47+ raise ValueError (f"check_interval must be >= 1, got { check_interval } " )
4648 self ._warning_threshold = warning_threshold
4749 self ._critical_threshold = critical_threshold
4850 self ._check_interval = check_interval
Original file line number Diff line number Diff line change @@ -45,6 +45,23 @@ def mock_read_text(self: Path) -> str:
4545 return mock_read_text
4646
4747
48+ # ---------------------------------------------------------------------------
49+ # __init__ — input validation
50+ # ---------------------------------------------------------------------------
51+
52+
53+ def test_check_interval_zero_raises () -> None :
54+ """check_interval=0 should raise ValueError at construction time."""
55+ with pytest .raises (ValueError , match = "check_interval must be >= 1" ):
56+ MemoryMonitor (check_interval = 0 )
57+
58+
59+ def test_check_interval_negative_raises () -> None :
60+ """Negative check_interval should raise ValueError at construction time."""
61+ with pytest .raises (ValueError , match = "check_interval must be >= 1" ):
62+ MemoryMonitor (check_interval = - 1 )
63+
64+
4865# ---------------------------------------------------------------------------
4966# check_memory_usage — no-op paths
5067# ---------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments