Skip to content

Find a Windows virtualenv at .venv\Scripts\python.exe - #7

Open
dieterstemmet wants to merge 2 commits into
unclebob:masterfrom
dieterstemmet:windows-venv
Open

dieterstemmet wants to merge 2 commits into
unclebob:masterfrom
dieterstemmet:windows-venv

Conversation

@dieterstemmet

@dieterstemmet dieterstemmet commented Oct 27, 2026 •

Copy link
Copy Markdown

Why

On Windows a venv keeps its interpreter in Scripts\python.exe, not bin/python. _python_executable checks only the bin/python paths. On Windows it misses the project's venv and falls back to python3, which runs the tests without the project's packages. The tests then fail, and every function scores 0% coverage.

What

_python_executable also checks .venv/Scripts/python.exe and venv/Scripts/python.exe, after the existing bin/python paths. Unix lookup order is unchanged.

Not included

Three tests in the suite fail on Windows before and after this change. All three come from Unix assumptions in the tests, not in crapper:

  • test_project_snapshot_is_readable_as_crap4clj_edn runs a shell script directly.
  • test_uml_loader_rejects_a_missing_viewer runs the zsh uml loader.
  • test_files_outside_the_project_keep_an_absolute_path compares a / path with a \ path.

I can send fixes for these separately if you want them.

Verified

  • test_python_executable_finds_a_windows_venv failed first (got python3), then passed.
  • Windows 11, Python 3.11: 144 passed. The 3 failures are the ones above, the same as before the change.
  • On a copy of dryer with its own venv, crapper ran its 80 tests under .venv\Scripts\python.exe and reported real coverage.
  • Linux (Ubuntu, aarch64, Python 3.12): 145 passed, 2 failed. The same 2 fail without this change (144 passed): test_project_snapshot_is_readable_as_crap4clj_edn and test_uml_loader_rejects_a_missing_viewer, because that box has no zsh or clj.
  • Not run on macOS.

Why: on Windows a venv keeps its interpreter in Scripts\python.exe, not bin/python. The lookup missed it, fell back to python3, and ran the tests without the project's packages, so every function scored 0% coverage.
What: _python_executable also checks .venv/Scripts/python.exe and venv/Scripts/python.exe, after the bin/python paths.
Proof: test_python_executable_finds_a_windows_venv failed first (got python3), then passed. On a copy of dryer with its own venv, crapper ran 80 passing tests under .venv\Scripts\python.exe and reported real coverage.
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.

1 participant