fix: prevent stdout.close() in tests for OSError EPIPE handler
The OSError exception handler for EPIPE errors was calling sys.stdout.close() without checking the AUTO_CLAUDE_TESTS flag, causing CI to fail on test_safe_print_os_error_epipe. This adds the same _IN_TESTS check that the BrokenPipeError handler already has. Fixes CI failure: test-python on test-coverage-improvements branch
This commit is contained in:
@@ -68,10 +68,12 @@ def safe_print(message: str, flush: bool = True) -> None:
|
||||
# Handle other pipe-related errors (EPIPE, etc.)
|
||||
if e.errno == 32: # EPIPE - Broken pipe
|
||||
_pipe_broken = True
|
||||
try:
|
||||
sys.stdout.close()
|
||||
except Exception:
|
||||
pass
|
||||
# Skip closing stdout during tests to avoid pytest capture issues
|
||||
if not _IN_TESTS:
|
||||
try:
|
||||
sys.stdout.close()
|
||||
except Exception:
|
||||
pass
|
||||
logger.debug("Output pipe closed (EPIPE)")
|
||||
else:
|
||||
# Re-raise unexpected OS errors
|
||||
|
||||
Reference in New Issue
Block a user