I think it would be useful if we could use a decorator at UnitTests that would specify which method/function is going to be tested. By doing so, we could get a more clear image from the test coverage report.
For example, in the following snippet, the coverage report should contain information only for the
squared_abs method and not for the
class MyClass(object): def __init__(self): pass def custom_abs(self, value): if value > 0: return value else: return -value def squared_abs(self, value): abs_value = self.custom_abs(value) return abs_value ** 2 class MyClassTest(unittest.TestCase): def setUp(self): self.instance = MyClass() @coverage(MyClass.squared_abs) def test_MyClass_method2(self): assert self.instance.squared_abs(-2) == 4
Something similar can be done by profilehooks.