Skip to content

tests/web/test_build.py::test_main_without_npm fails on machines with npm in the fallback dirs #36

Closed

Description

@falbany
FAILED tests/web/test_build.py::test_main_without_npm - assert 0 == 1
1 failed, 1318 passed, 245 skipped

The test monkeypatches shutil.which to return None and asserts main() == 1 with "npm not found" on stderr. Since the Node.js fallback detection landed (commit 4993483), main() also probes _NODE_FALLBACK_DIRS (src/profiles/web/build.py:16-21) — on machines where /opt/homebrew/bin/npm (macOS) or /usr/local/bin/npm (Linux) exists, npm is found anyway and main() returns 0.

So the test is environment-dependent: it only passes on machines with no npm in the hardcoded fallback locations, and is currently red on this repo's own dev machine.

Fix

  • In the test, also monkeypatch _NODE_FALLBACK_DIRS to point at an empty temp dir (or make the discovery roots a parameter of main()).
  • While there: the final monkeypatch.setattr(shutil, "which", original_which) is redundant (pytest undoes monkeypatches) — remove it.

Activity

  1. added
    bug
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions