mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-31 19:16:29 +00:00
test(gateway): trim docstrings
This commit is contained in:
parent
3ec5fb076e
commit
12fdaeaf1a
1 changed files with 47 additions and 0 deletions
47
tests/gateway/test_71671_faulthandler_no_stderr.py
Normal file
47
tests/gateway/test_71671_faulthandler_no_stderr.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
"""Regression: #71671 — gateway must survive faulthandler.enable() with sys.stderr=None."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import faulthandler
|
||||
import os
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_faulthandler_enable_falls_back_when_stderr_is_none(tmp_path):
|
||||
was_enabled = faulthandler.is_enabled()
|
||||
if was_enabled:
|
||||
faulthandler.disable()
|
||||
|
||||
real_stderr = sys.stderr
|
||||
sys.stderr = None
|
||||
try:
|
||||
with pytest.raises(RuntimeError, match="sys.stderr is None"):
|
||||
faulthandler.enable()
|
||||
|
||||
log_path = tmp_path / "gateway_faulthandler.log"
|
||||
fh = open(log_path, "a", encoding="utf-8")
|
||||
try:
|
||||
faulthandler.enable(file=fh, all_threads=True)
|
||||
assert faulthandler.is_enabled()
|
||||
assert log_path.exists()
|
||||
finally:
|
||||
faulthandler.disable()
|
||||
fh.close()
|
||||
finally:
|
||||
sys.stderr = real_stderr
|
||||
if was_enabled:
|
||||
faulthandler.enable()
|
||||
|
||||
|
||||
def test_gateway_run_keeps_faulthandler_guard():
|
||||
src = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
|
||||
"gateway", "run.py",
|
||||
)
|
||||
with open(src, encoding="utf-8") as f:
|
||||
text = f.read()
|
||||
assert "try:\n faulthandler.enable()\n except (RuntimeError, ValueError, OSError):" in text, (
|
||||
"gateway/run.py must keep the try/except guard around faulthandler.enable() (see #71671)"
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue