From ddceda73f0e27a5205ea9001325ca100bfa47648 Mon Sep 17 00:00:00 2001 From: ANSHUL SINGH <72524975+ekanshul@users.noreply.github.com> Date: Wed, 23 Sep 2026 17:37:09 +0000 Subject: [PATCH] Fix Windows man-page availability check os.system == 'nt' is always False because os.system is a function. Use os.name == 'nt' so the guard actually skips man on Windows. Closes httpie/cli#1898 --- CHANGELOG.md | 4 ++++ httpie/output/ui/man_pages.py | 2 +- tests/test_windows.py | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0497ac3508..3c3b8bc606 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] + +- Fixed the Windows man-page availability check, which compared `os.system` (a function) to `'nt'` instead of `os.name`. ([#1898](https://github.com/httpie/cli/issues/1898)) + ## [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/output/ui/man_pages.py b/httpie/output/ui/man_pages.py index 0ba4974578..589b928553 100644 --- a/httpie/output/ui/man_pages.py +++ b/httpie/output/ui/man_pages.py @@ -18,7 +18,7 @@ def is_available(program: str) -> bool: Check whether `program`'s man pages are available on this system. """ - if NO_MAN_PAGES or os.system == 'nt': + if NO_MAN_PAGES or os.name == 'nt': return False try: process = subprocess.run( diff --git a/tests/test_windows.py b/tests/test_windows.py index 80d392ae8f..1f334a30ae 100644 --- a/tests/test_windows.py +++ b/tests/test_windows.py @@ -15,6 +15,15 @@ def test_windows_colorized_output(self, httpbin): http(httpbin + '/get', env=Environment()) +def test_is_available_false_on_windows(monkeypatch): + # Regression: os.system == 'nt' is always False (os.system is a function). + from httpie.output.ui import man_pages + + monkeypatch.setattr(man_pages.os, 'name', 'nt') + monkeypatch.setattr(man_pages, 'NO_MAN_PAGES', False) + assert man_pages.is_available('http') is False + + class TestFakeWindows: def test_output_file_pretty_not_allowed_on_windows(self, tmp_path, httpbin): env = MockEnvironment(is_windows=True)