Skip to content

patch = subprocess misses .coverage datafiles when subprocess is in another directory #2025

@marcelotduarte

Description

@marcelotduarte

Describe the bug
When the subprocess is in another directory (using cwd), patch = subprocess misses the coverage.

To Reproduce

  1. Using Python 3.9 to 3.13
  2. Using coverage 7.10.2 and 7.10.3a0.dev1 (from git+https://github.com/nedbat/coveragepy.git@d9683239c9ede7e292eb3d58e6051b184a5dcbf2)
  3. commit to check: marcelotduarte/cx_Freeze@c5e210e
  4. commit that fix: marcelotduarte/cx_Freeze@86913f5

Expected behavior
The .coverage data files must be stored together in the main directory.

Additional context
I'm replacing pytest-cov with pure coverage now that it supports patching in the subprocess. Previously, this wasn't possible. The change is quite simple (see 3), but I ran into this issue. I made the commits into my project separately to make it easier to show this bug.

In local testing on Linux, I was getting 56.36% coverage, but after the change, this coverage dropped to 47.03% (on GitHub, the coverage is 83% and then dropped to 62%).

After much testing, I discovered the problem and resolved it by copying the data files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions