Skip to content

patch = subprocess not working in github actions specifically on Windows #2022

@jepler

Description

@jepler

Describe the bug
I want to use [run]patch = subprocess on Windows in github actions, but I get a ModuleNotFoundError and coverage is incomplete.

To Reproduce

  1. Python 3.x (=3.13.5) installed with actions/setup-python on windows-latest in github actions
  2. The minimized test case is at https://github.com/jepler/covsub
  3. coverage installed with pip install coverage after pip install wheel. No other non-standard packages required
  4. Run the github actions

Expected behavior
The subprocess patch should work in all 3 environments (linux, windows, and macos). However, it fails on Windows:


Error processing line 1 of C:\hostedtoolcache\windows\Python\3.13.5\x64\subcover.pth:

  Traceback (most recent call last):
    File "<frozen site>", line 207, in addpackage
    File "<string>", line 1, in <module>
  ModuleNotFoundError: No module named 'coverage'

Remainder of file ignored
function 1

Furthermore, the overall project coverage is lower than expected, 73% instead of 96%, because the sub-processes are not covered.

(Without --fail-under= the actions would have been green because the subprocesses do return a success value)

Additional context

This is a minimized reproducer. I ran into a problem in the context of an existing project when I tried to adapt it to use patch=subprocess.

I have some vague suspicions that maybe there's a problem with the ordering of .pth files or something like that, but it's difficult to inspect the state of a github actions vm after a failure and I didn't spend much time trying to determine the underlying cause(s).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions