pytest-dev/pytest-cov

Protocol method placeholders marked as untested

andrewlalis opened this issue · 1 comments

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.

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