Closed mikegrima closed 1 year ago
I did an additional test without the context being set to fork
, and it does successfully report the code as covered. It fails when the process is set to fork.
I'll also add that I did review this issue but the suggested fix didn't work for me: https://github.com/pytest-dev/pytest-cov/issues/165
Yes but that is irrelevant now since multiprocessing support was removed in pytest-cov 4.0. You can try adding this in your coveragerc for the support bultin support from coverage:
[run]
concurrency = multiprocessing
parallel = true
sigterm = true
Thanks @ionelmc ! Those changes worked for me. I struggled to find these details though. I mostly reviewed the documentation on this page: https://pytest-cov.readthedocs.io/en/latest/subprocess-support.html. I would be happy to make a PR to add the above details.
Summary
Hello. I am making use of a
ProcessPoolExecutor
context manager and all code that runs within it is not deemed as covered. I am running this on macOS.I execute this in tox normally, but this has the same issue outside of tox as well.
The command I run is:
pytest --cov --cov-report term-missing tests -n auto
. The behavior is the same with or without-n auto
forpytest-xdist
.Expected vs actual result
Expected to have the code covered. The actual result is that the code it not seen as covered.
Reproducer
Here is essentially the code that I have:
main.py:
test_main.py:
Run
pytest --cov --cov-report term-missing -n auto
for my tests.This is the output:
Per the output, lines 18-20 are missing, but they are in fact executed.
Versions
I should hopefully have the code OSS'd soon so that could provide more context, but in the meantime, the code above demonstrates the issue.