pytest-dev / pytest-cov

Coverage plugin for pytest.
MIT License
1.76k stars 212 forks source link

Protocol method placeholders marked as untested #593

Closed andrewlalis closed 1 year ago

andrewlalis commented 1 year ago

Summary

When computing the coverage of a project, I am getting cases where the placeholder body of a protocol method is considered as untested code. I would expect that the body of protocol methods would not be marked as untested.

Versions

python version 3.11 pytest version 7.3.0 pytest-cov version 4.0.0

Code

from typing import Protocol

class Example(Protocol):
    def do_something() -> None:
        ...

In the above code, the line containing ... is marked as untested, despite the fact that it cannot, by definition, be tested because protocols cannot be implemented directly.

RonnyPfannschmidt commented 1 year ago

As far as Coverage is concerned, they never executed, i believe this would also happen with vanilla coverage.py