Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

- Fixed `-qq` leaking warnings when standard output is redirected. ([#1978](https://github.com/httpie/cli/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))
Expand Down
2 changes: 1 addition & 1 deletion httpie/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,15 @@ def test_quiet_quiet_with_check_status_non_zero(self, httpbin):
)
assert not r.stderr

def test_quiet_quiet_with_check_status_non_zero_pipe(self, httpbin):
@pytest.mark.parametrize('quiet_flags', [('--quiet', '--quiet'), ('-qq',)])
def test_quiet_quiet_with_check_status_non_zero_pipe(self, httpbin, quiet_flags):
r = http(
'--quiet', '--quiet', '--check-status', httpbin + '/status/500',
*quiet_flags, '--check-status', httpbin + '/status/500',
tolerate_error_exit_status=True,
env=MockEnvironment(stdout_isatty=False)
)
assert 'http: warning: HTTP 500' in r.stderr
assert not r.stderr
assert r.exit_status == ExitStatus.ERROR_HTTP_5XX

@mock.patch('httpie.core.program')
@pytest.mark.parametrize('flags, expected_warnings', [
Expand All @@ -110,10 +112,12 @@ def warn_and_run(*args, **kwargs):

assert len(record) == expected_warnings

def test_double_quiet_on_error(self, httpbin):
@pytest.mark.parametrize('stdout_isatty', [True, False])
def test_double_quiet_on_error(self, httpbin, stdout_isatty):
r = http(
'-qq', '--check-status', '$$$this.does.not.exist$$$',
tolerate_error_exit_status=True,
env=MockEnvironment(stdout_isatty=stdout_isatty),
)
assert not r
assert 'Couldn’t resolve the given hostname' in r.stderr
Expand Down
Loading