--branch and --concurrency are conflicting

Issue #495 wontfix
Gabriel Duman created an issue

i'm not sure if these two feature are meant to be combined.

this is a test script to reproduce

import multiprocessing
import sys

def func(value):
    if value % 2 == 0:
        print value, 'is even'
        print value, 'is odd'

if __name__ == "__main__":  # pragma: no cover
    values = range(2)
    pool = multiprocessing.Pool(processes=2)
    pool.map(func, values)

and here is the result

> coverage --version
Coverage.py, version 4.1 with C extension
Documentation at https://coverage.readthedocs.io
> coverage run --branch --concurrency=multiprocessing test.py
0 is even
1 is odd
> coverage combine
Can't combine line data with arc data
> coverage report
Name      Stmts   Miss Branch BrPart  Cover
test.py       6      3      2      0    38%

when i remove the argument --branch the combine command works. sometimes i get a warning that no data was collected. i cannot reproduce this at the moment.

> coverage run --concurrency=multiprocessing test.py
0 is even
1 is odd
Coverage.py warning: No data was collected.
> coverage combine
> coverage report
Name      Stmts   Miss  Cover
test.py       6      0   100%

Comments (4)

  1. Ned Batchelder repo owner

    @gabber7 Thanks for the report. You can work around this limitation by putting "[run] branch=True" into a .coveragerc file.

  2. Ned Batchelder repo owner

    I'm going to leave this as a documented limitation of the command-line flags. Once programs get complicated enough to use multiprocessing, options should go in a configuration file.

  3. Log in to comment