coveragepy
coveragepy copied to clipboard
Issue with coverage and pymp
Describe the bug Issue with coverage and pymp (https://github.com/classner/pymp)
- It is giving CoverageWarning: No data was collected. (no-data-collected)
- For other libraries like multiprocessing, it is working as expected.
To Reproduce
# sample.py
def div(a, b):
if b == 0:
raise ValueError("b == 0")
return a//b
# test_sample.py
from sample import div
import unittest
from multiprocessing import Process
import pymp
class TestSample(unittest.TestCase):
def test_div(self):
a = 5
b = 2
# p = Process(target=div, args=(a, b ))
# p.start()
# p.join()
with pymp.Parallel(2) as p:
for i in p.range(1):
div(a, b)
if __name__ == "__main__":
unittest.main()
# .coveragerc
[run]
include = *sample*
parallel = True
concurrency = multiprocessing,thread
[report]
ignore_errors = True
[html]
# Title that will be displayed in coverage report
title = Code Coverage Report
-
What version of Python are you using? 3.9.7
-
What version of coverage.py shows the problem? 6.2
-
What versions of what packages do you have installed? pymp-pypi 0.4.5
-
What commands did you run?
# Using pymp
shell> coverage run test_sample.py
../python3.9/site-packages/coverage/control.py:768: CoverageWarning: No data was collected. (no-data-collected)
self._warn("No data was collected.", slug="no-data-collected")
.
----------------------------------------------------------------------
Ran 1 test in 0.181s
OK
../python-3.9/std/lib64/python3.9/site-packages/coverage/control.py:768: CoverageWarning: No data was collected. (no-data-collected)
shell> coverage combine && coverage report
Name Stmts Miss Cover
------------------------------------
sample.py 4 1 75%
test_sample.py 12 0 100%
------------------------------------
TOTAL 16 1 94%
# Using multiprocessing: no warnings
shell> coverage run test_sample.py
.
----------------------------------------------------------------------
Ran 1 test in 0.181s
OK
shell> coverage combine && coverage report
Name Stmts Miss Cover
------------------------------------
sample.py 4 1 75%
test_sample.py 12 0 100%
------------------------------------
TOTAL 16 1 94%
Expected behavior I was not expecting this warning to come up as data was collected.
PS: Also tried upgrading coverage and pymp to the latest version: didn't help. TIA for looking into this.
Hi, sorry I let this sit so long. I see the warning you mean, but I also see that after coverage combine, the data is all present. I'm not sure why the warning is happening. Are you finding that data is actually missing, or is it a spurious warning?
Hi @nedbat! Apologies for the late reply. It is just a spurious warning as the coverage numbers seem to be correct. Thanks again for looking into this!