Open ionite34 opened 1 year ago
Describe the bug When pytest launches a test using multiprocessing.Process, lines hit are not recorded as covered.
multiprocessing.Process
To Reproduce Here is a repo with a minimal reproducible example, along with a CI run showing coverage not being hit. https://github.com/ionite34/_demo_pytest_subprocess
Module file: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/foo/mod.py
def add(a, b): return a + b def sub(a, b): return a - b
Test file: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/tests/test_mod.py
import pytest from foo import mod def test_add(): assert mod.add(1, 2) == 3 @pytest.mark.run_in_subprocess def test_sub(): assert mod.sub(1, 1) == 0
Multiprocessing code for run_in_subprocess: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/tests/conftest.py
run_in_subprocess
Expected behavior the function sub is showed as not covered, as can be seen here https://github.com/ionite34/_demo_pytest_subprocess/actions/runs/4015443879/jobs/6897178045#step:5:21
sub
html artifact also shows line hit by subprocess as missing: https://github.com/ionite34/_demo_pytest_subprocess/suites/10597630040/artifacts/528237599
Have you specified concurrency=multiprocessing in your configuration? https://coverage.readthedocs.io/en/7.2.1/config.html#run-concurrency
concurrency=multiprocessing
Describe the bug When pytest launches a test using
multiprocessing.Process
, lines hit are not recorded as covered.To Reproduce Here is a repo with a minimal reproducible example, along with a CI run showing coverage not being hit. https://github.com/ionite34/_demo_pytest_subprocess
Module file: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/foo/mod.py
Test file: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/tests/test_mod.py
Multiprocessing code for
run_in_subprocess
: https://github.com/ionite34/_demo_pytest_subprocess/blob/main/tests/conftest.pyExpected behavior the function
sub
is showed as not covered, as can be seen here https://github.com/ionite34/_demo_pytest_subprocess/actions/runs/4015443879/jobs/6897178045#step:5:21html artifact also shows line hit by subprocess as missing: https://github.com/ionite34/_demo_pytest_subprocess/suites/10597630040/artifacts/528237599