microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.31k stars 1.18k forks source link

Empty lines count towards coverage #24171

Open bpasero opened 2 weeks ago

bpasero commented 2 weeks ago

Testing #24156

I had this test:

import pytest
import time

@pytest.mark.parametrize("num", range(1, 10))
# this is unclear

def test_num(num):
    time.sleep(0.3)
    assert True
    # nd even more

And the coverage without empty lines is at 85.71% but now at 66.67%:

Image

eleanorjboyd commented 2 weeks ago

gave this a try and am not seeing this- what version of python are you on? Are any of those empty lines actually containing spaces?Image

bpasero commented 2 weeks ago

@eleanorjboyd I am using 3.12.5

Image

Find the file with new lines attached:

test_wait_parameterized.py.zip

eleanorjboyd commented 2 weeks ago

huh even with the right python version I am not seeing the comments impact code coverage. Did you have any pytest arguments during this run? I think I can just close this since the decision on the code coverage percentage / numbers are dictated by coverage.py and communicated the extension so in the end we don't have control over the numbers as long as they are getting there correctly. You could always try running it in the terminal python -m pytest --cov=. to see if you get a similar result because our goal is to always mirror the tool behavior.