diff --git a/CHANGELOG.md b/CHANGELOG.md index 0497ac3508..3b76339b26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ This document records all notable changes to [HTTPie](https://httpie.io). This project adheres to [Semantic Versioning](https://semver.org/). +## Unreleased + +- Fix `--quiet` (and `-qq`) not suppressing warnings/errors when stdout is redirected. ([#1978](https://github.com/httpie/httpie/issues/1978)) + ## [3.2.4](https://github.com/httpie/cli/compare/3.2.3...3.2.4) (2024-11-01) - Fix default certs loading and unpin `requests`. ([#1596](https://github.com/httpie/cli/issues/1596)) diff --git a/httpie/context.py b/httpie/context.py index 2a54f46916..fd7e7c6ecc 100644 --- a/httpie/context.py +++ b/httpie/context.py @@ -168,7 +168,7 @@ def as_silent(self) -> Iterator[None]: self.stderr = original_stderr def log_error(self, msg: str, level: LogLevel = LogLevel.ERROR) -> None: - if self.stdout_isatty and self.quiet >= LOG_LEVEL_DISPLAY_THRESHOLDS[level]: + if self.quiet >= LOG_LEVEL_DISPLAY_THRESHOLDS[level]: stderr = self.stderr # Not directly /dev/null, since stderr might be mocked else: stderr = self._orig_stderr diff --git a/tests/test_output.py b/tests/test_output.py index 2242177dbc..9f4eda6519 100644 --- a/tests/test_output.py +++ b/tests/test_output.py @@ -89,7 +89,9 @@ def test_quiet_quiet_with_check_status_non_zero_pipe(self, httpbin): tolerate_error_exit_status=True, env=MockEnvironment(stdout_isatty=False) ) - assert 'http: warning: HTTP 500' in r.stderr + # Warnings are suppressed with -qq regardless of whether stdout + # is a TTY, as documented ("Provide twice to suppress warnings as well"). + assert not r.stderr @mock.patch('httpie.core.program') @pytest.mark.parametrize('flags, expected_warnings', [