I have a Python application I'm running within a Docker container. That application is normally started with the command /usr/local/bin/foo_service
, which is a Python entry point (so it's just a Python file).
I want to collect code coverage for this application while running functional tests against it. I've found that coverage run /usr/local/bin/foo_service
works nicely and, once the application exits, outputs a coverage file whose report appears accurate.
However, this is in the single-process mode. The application has another mode that uses the multiprocessing
module to fork two or more child processes. I'm not sure if this is compatible with the the way I'm invoking coverage. I did coverage run --parallel-mode /usr/local/bin/foo_service -f 4
, and it did output [one] coverage [file] without omitting any errors, but I don't know that this is correct. I half-expected it to output a coverage file per-process, but I don't know that it should do that. I couldn't find much coverage (pardon the pun) of this topic in the documentation.
Will this work? Or do I need to forego using the coverage
binary and instead use the coverage
Python API within my forking code?
$ python --version
Python 3.7.4
$ coverage --version
Coverage.py, version 4.5.3 with C extension