Misleading branch coverage of empty methods · Issue #129 · nedbat/coveragepy (original) (raw)

Originally reported by Christian Heimes (Bitbucket: tiran, GitHub: tiran)


Branch coverage of an abc.abstractmethod with just a doc string in the method, shows the decorator line as uncovered branch that never reaches "exit".

#!python
import abc

class AExample(object):
    @abc.abstractmethod  # exit
    def method(self):
        """doc
        """

class Example(AExample):
    def method(self):
        return True

Example().method()

When I replace the doc string with "pass", the decorator line is a covered branch. However the pass statement is not covered at all.

#!python

class AExample(object):
    @abc.abstractmethod 
    def method(self): 
        pass  # uncovered