ptvsd import suppresses coverage reporting
rjungwirth opened this issue · 2 comments
Environment data
- PTVSD version: 4.3.2
- OS and version: Mac OS X 10.14.6
- Python version (& distribution if applicable, e.g. Anaconda): python 3.7.3 + coverage-5.0.4
- Using VS Code or Visual Studio: N/A
Actual behavior
import ptvsd module suppresses coverage reporting for all execution after import
Expected behavior
importing ptvsd should not cause coverage reporting to be supressed
Steps to reproduce:
- run this bash script:
#!/usr/bin/env bash
rm -rf _venv
python3 -m venv _venv
./_venv/bin/pip3 install --upgrade pip
./_venv/bin/pip3 install coverage ptvsd
cat >foo_test.py<<EOF
import sys
if len(sys.argv) > 1: import ptvsd
def do_something(x):
return x
do_something(5)
EOF
_venv/bin/coverage run --omit=_venv/* foo_test.py
if $(_venv/bin/coverage report | fgrep foo_test.py | fgrep -q '100%'); then echo 'NO IMPORT PTVSD SUCCESS'; else echo 'NO IMPORT PTVSD FAILURE ';fi
_venv/bin/coverage run --omit=_venv/* foo_test.py 1
if $(_venv/bin/coverage report | fgrep foo_test.py | fgrep -q '100%'); then echo 'IMPORT PTVSD SUCCESS'; else echo 'IMPORT PTVSD FAILURE';fi
observe:
test case 1 succeeds (no importing PTVSD == full coverage reporting)
test case 2 fails: importing PTVSD causes coverage reporting to stop for all subsequent execution steps in script
this is a big "gotcha"! Simply importing PTVSD suppresses code coverage regardless of whether you use the functionality or not.
Please add a note to the documentation so others don't waste their time figuring out what is wrong with their code!
This shouldn't be the case for ptvsd 5.x / debugpy anymore, since it doesn't import pydevd unless and until the module is actually used - merely importing it does nothing.