Skip to content

fix(ci): platform-aware pipx detection test (Windows matrix)#461

Draft
curdriceaurora wants to merge 1 commit into
mainfrom
claude/friendly-euler-3wnUn
Draft

fix(ci): platform-aware pipx detection test (Windows matrix)#461
curdriceaurora wants to merge 1 commit into
mainfrom
claude/friendly-euler-3wnUn

Conversation

@curdriceaurora
Copy link
Copy Markdown
Owner

Summary

Restores green status of the CI Full Matrix / Test Windows (Python 3.12) job, which has been the sole failing matrix slot on recent scheduled runs (e.g. run 26871404355 on commit dd13452).

Failure detected

Single deterministic test failure, only on Windows + Python 3.12:

FAILED tests/cli/test_doctor.py::TestInstallMethodDetection::test_detect_pipx_via_pipx_home_env
    - AssertionError: assert 'pip' == 'pipx'

All four other matrix jobs (Linux py3.11, Linux py3.12, macOS py3.12, coverage gate) pass on the same commit.

Root cause

The test (lines 254–262 of tests/cli/test_doctor.py) hardcoded POSIX-style paths:

custom_home = "/custom/pipx"
fake_exe    = "/custom/pipx/venvs/fo-core/bin/python"

But the production code _detect_install_method() in src/cli/doctor.py:119 builds its comparison prefix with the platform's join + separator:

if exe_path.startswith(os.path.join(pipx_home, "venvs") + os.sep):

On Windows this evaluates to "/custom/pipx\venvs\" (mixed separators because pipx_home is forward-slash but os.sep == "\\"). The startswith check against a pure forward-slash exe_path always fails, so the function returns "pip" and the assertion blows up.

This is a test-side bug — the production code's behaviour on real Windows installs (where both PIPX_HOME and sys.executable use \\) is correct. The other tests in the same class already use either platform-mocked os.path.expanduser or os.path.expanduser(...) directly, which is why they pass on Windows.

Fix

Build the test inputs with os.sep + os.path.join so the same separator semantics are exercised on POSIX and Windows:

custom_home = os.sep + os.path.join("custom", "pipx")
fake_exe    = os.path.join(custom_home, "venvs", "fo-core", "bin", "python")
  • POSIX: custom_home="/custom/pipx", prefix "/custom/pipx/venvs/" → matches ✓
  • Windows: custom_home="\\custom\\pipx", prefix "\\custom\\pipx\\venvs\\" → matches ✓

Verification

Local cross-platform simulation using posixpath and ntpath modules:

Inputs POSIX Windows
New (os.sep-aware) pipx pipx
Old (hardcoded /) pipx pip ✗ (reproduces failure)

Other local checks:

  • ruff check tests/cli/test_doctor.py — passes
  • ruff format --check — already formatted
  • G1 (pre-commit-staged absolute-path) — clean
  • G2 (scripts/check_test_hardcoded_paths.py full-suite scan) — clean

The Linux/macOS jobs of the same Matrix workflow already passed on the unchanged production code, so they will continue to pass under the new test inputs (POSIX path → same startswith match).

Trade-offs

  • No production code change — the implementation is correct on real Windows installs (where PIPX_HOME would itself use \\). The fix is scoped to the test simulating realistic per-platform inputs.
  • No test weakening — the assertion still verifies that a PIPX_HOME-based pipx executable is detected as "pipx"; only the input construction is now platform-aware.

Impacted areas

  • tests/cli/test_doctor.py — single test function (test_detect_pipx_via_pipx_home_env), +6/-2.

Links


Generated by Claude Code

`tests/cli/test_doctor.py::TestInstallMethodDetection::test_detect_pipx_via_pipx_home_env`
hardcoded POSIX-style paths (`/custom/pipx`, `/custom/pipx/venvs/...`)
while `_detect_install_method()` builds its comparison prefix with
`os.path.join(pipx_home, "venvs") + os.sep`. On Windows this produces
`/custom/pipx\venvs\` which never `startswith`-matches a forward-slash
`exe_path`, so the test returns 'pip' instead of 'pipx'.

Fix: build `custom_home` and `fake_exe` with `os.sep` + `os.path.join`
so the same join logic is exercised on both POSIX and Windows. Verified
cross-platform with the ntpath/posixpath modules (POSIX → 'pipx',
Windows → 'pipx', old inputs on Windows → 'pip' reproduces the failure).

Restores the green status of the "CI Full Matrix / Test Windows
(Python 3.12)" job (run 26871404355).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 58b6a3f8-789e-415f-a3ea-ab8a0ee94f0b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/friendly-euler-3wnUn

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants