running py.tests with coverage for multiple processes

56 views
Skip to first unread message

Sol Simpson

unread,
Apr 3, 2016, 11:55:26 AM4/3/16
to psychopy-dev
Anyone know how to get the tests to run with coverage and report it for code run in the main process as well as any subprocesses?

I found the pytest-cov package and installed it, but when I run:

cd path/to/psychopy/psychopy

py.test --cov=psychopy tests/iohub_tests

I get coverage that only shows the files used in the psychopy (main) process; none of the iohub subprocess files have coverage even listed. 
The iohub subprocess runs psychopy/iohub/launchHubProcess.py, which uses iohub/server.py and many other files that are not in the coverage output report at all:

platform win32 -- Python 2.7.11, pytest-2.8.1, py-1.4.30, pluggy-0.3.1
rootdir: D:\.....\psychopy, inifile: pytest.ini
plugins: cov-2.2.1
collected 20 items

tests\test_iohub\test_computer.py ....s
tests\test_iohub\test_event_get_and_clear.py ....
tests\test_iohub\test_keyboard.py ..........
tests\test_iohub\test_launch.py .
--------------- coverage: platform win32, python 2.7.11-final-0 ---------------
Name                                           Stmts   Miss  Cover
------------------------------------------------------------------
__init__.py                                       27      3    89%
clock.py                                          77     39    49%
colors.py                                         22     15    32%
constants.py                                      10      0   100%
contrib\__init__.py                                0      0   100%
contrib\lazy_import.py                           158     81    49%
core.py                                           66     44    33%
event.py                                         344    285    17%
hardware\__init__.py                              67     56    16%
iohub\__init__.py                                 24      6    75%
iohub\client\__init__.py                         924    516    44%
iohub\client\keyboard.py                         130     30    77%
iohub\constants.py                               821    299    64%
iohub\devices\__init__.py                        506    259    49%
iohub\devices\display\__init__.py                279    236    15%
iohub\devices\experiment\__init__.py             115     57    50%
iohub\devices\keyboard\__init__.py               101     56    45%
iohub\devices\keyboard\win32.py                  167    141    16%
iohub\devices\mouse\__init__.py                  236    149    37%
iohub\devices\mouse\win32.py                      93     59    37%
iohub\errors.py                                   23     14    39%
iohub\lazy_import.py                             228    111    51%
iohub\net.py                                     213    133    38%
iohub\util\__init__.py                           151     89    41%
iohub\util\clock.py                               50     38    24%
iohub\util\dialogs.py                            122     80    34%
iohub\util\fix_encoding.py                       186     82    56%
logging.py                                       121     54    55%
makeMovies.py                                    186    160    14%
monitors\__init__.py                               5      3    40%
monitors\calibData.py                              4      0   100%
monitors\calibTools.py                           574    482    16%
platform_specific\__init__.py                     16      9    44%
platform_specific\win32.py                        42     22    48%
preferences\__init__.py                            4      0   100%
preferences\preferences.py                       133     43    68%
tests\__init__.py                                  0      0   100%
tests\test_iohub\__init__.py                       1      0   100%
tests\test_iohub\test_computer.py                 87      1    99%
tests\test_iohub\test_event_get_and_clear.py      57      0   100%
tests\test_iohub\test_keyboard.py                 44      0   100%
tests\test_iohub\test_launch.py                   12      0   100%
tests\test_iohub\testutil.py                      28      0   100%
tests\utils.py                                   135    114    16%
tools\__init__.py                                  1      0   100%
tools\arraytools.py                               74     66    11%
tools\attributetools.py                           62     50    19%
tools\colorspacetools.py                          91     81    11%
tools\coordinatetools.py                          45     38    16%
tools\monitorunittools.py                        124     94    24%
tools\typetools.py                                11      6    45%
tools\versionchooser.py                          136    106    22%
visual\__init__.py                                16      2    88%
visual\basevisual.py                             574    493    14%
visual\filters.py                                117     98    16%
visual\gamma.py                                  111     95    14%
visual\globalVars.py                               3      0   100%
visual\grating.py                                194    170    12%
visual\helpers.py                                173    152    12%
visual\image.py                                  154    132    14%
visual\shaders.py                                 53     33    38%
visual\text.py                                   342    295    14%
visual\window.py                                 876    773    12%
web.py                                           267    231    13%
------------------------------------------------------------------
TOTAL                                          10013   6681    33%

==================== 19 passed, 1 skipped in 86.88 seconds ====================


Jon

unread,
Apr 12, 2016, 12:30:35 PM4/12/16
to psychopy-dev
Sorry, no. I don't know how to handle that. One thing I'll try though, just in case it helps, is to see what happens when we plug the code coverage checking of the github requests into codecov.io (an alternative to coveralls.io who we've used so far). It might be that they use the same underlying technology but we might find it "just works". 

If not I think we need to email authors (either at codecov.io or at pytest)

cheers
Jon

Jon

unread,
Apr 12, 2016, 12:34:16 PM4/12/16
to psychopy-dev
But searching this page for "subprocess" suggests that it should be handled:
Reply all
Reply to author
Forward
0 new messages