Python coverage is 0% on Windows: project virtualenv is only looked up at .venv/bin/python

Open Beginner friendly
#43 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
tooling

Research direction

Start in _python_executable in src/crapper/runners.py, where the candidate interpreter paths are listed; the fallback to python3 and the warning that coverage is missing are there too. Add the Windows venv locations (.venv/Scripts/python.exe, venv/Scripts/python.exe) and change the fallback on os.name == "nt" to sys.executable or python. The issue also notes the ./crapper launcher hard-codes python3 and .venv/bin/python; treat that as a separate, optional follow-up. Done means running crapper src on Windows picks up the project venv and reports non-zero Python coverage instead of the Store alias warning.

Written by the indexing model from the issue text.

Description

On Windows, a virtualenv puts its interpreter at .venv\Scripts\python.exe, not .venv/bin/python. _python_executable in src/crapper/runners.py only checks .venv/bin/python and venv/bin/python, then falls back to python3. On a stock Windows install, python3 is the Microsoft Store alias, which only prints an "install from the Store" message. Coverage never runs, and every Python function scores 0% coverage.

Repro (Windows 11, Git Bash, Python 3.14, crapper c757ec7)

  1. A small pytest project with .venv created by python -m venv .venv and with pytest and coverage installed in it.
  2. Run crapper src.
  3. stderr prints the Store alias message and "coverage is missing … Python coverage will score 0%". Every row shows 0.0%.

Expected: coverage measured with the project's venv.

Workaround: generate target/coverage/python/lcov.info by hand and pass --use-existing-coverage. That gives correct numbers.

Possible fix: also check .venv/Scripts/python.exe and venv/Scripts/python.exe. When neither exists, fall back to sys.executable (or python) instead of python3 on os.name == "nt".

A related detail: the ./crapper launcher script uses python3 and .venv/bin/python, so on Windows the tool has to be installed by hand with python -m venv .venv && .venv/Scripts/python -m pip install -e ..

Dominant language
Python
Stars
255
Forks
101
Avg merge
7m
Merged PRs (30d)
4

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from unclebob/crapper

All issues in unclebob/crapper

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.