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/).

## [3.2.5-dev](https://github.com/httpie/cli/compare/3.2.4...master) (unreleased)

- Fixed the Windows check in the man page lookup, which compared `os.system` to `'nt'` and never matched. ([#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))
Expand Down
3 changes: 2 additions & 1 deletion httpie/output/ui/man_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import subprocess
import os
from httpie.compat import is_windows
from httpie.context import Environment


Expand All @@ -18,7 +19,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 is_windows:
return False
try:
process = subprocess.run(
Expand Down
47 changes: 47 additions & 0 deletions tests/test_man_pages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import pytest

from httpie.output.ui import man_pages


@pytest.fixture(autouse=True)
def enable_man_pages(mocker):
mocker.patch.object(man_pages, 'NO_MAN_PAGES', False)
mocker.patch.object(man_pages, 'is_windows', False)


def test_is_available_on_windows(mocker):
# see https://github.com/httpie/cli/issues/1898
mocker.patch.object(man_pages, 'is_windows', True)
run = mocker.patch.object(man_pages.subprocess, 'run')
run.return_value.returncode = 0

assert man_pages.is_available('http') is False
run.assert_not_called()


def test_is_available_when_disabled(mocker):
mocker.patch.object(man_pages, 'NO_MAN_PAGES', True)
run = mocker.patch.object(man_pages.subprocess, 'run')

assert man_pages.is_available('http') is False
run.assert_not_called()


def test_is_available_when_man_page_exists(mocker):
run = mocker.patch.object(man_pages.subprocess, 'run')
run.return_value.returncode = 0

assert man_pages.is_available('http') is True


def test_is_available_when_man_page_is_missing(mocker):
run = mocker.patch.object(man_pages.subprocess, 'run')
run.return_value.returncode = 1

assert man_pages.is_available('http') is False


def test_is_available_when_man_is_not_installed(mocker):
mocker.patch.object(man_pages.subprocess, 'run', side_effect=FileNotFoundError)

assert man_pages.is_available('http') is False
Loading