Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude private methods in coverage

Is there any way to exclude private methods during testing coverage?

In my .coveragerc I tried:

[report]
exclude_lines = 
    __*

But it seems to exclude methods such as long_method_name

Is ther any way to do it without listing all methdos?

EDIT

I want methods such as __add__ which have simillar syntax to private to be included in the tests.

like image 409
MaLiN2223 Avatar asked Oct 25 '25 14:10

MaLiN2223


1 Answers

From the docs:

class MyObject(object):
    def __init__(self):
        blah1()
        blah2()

    def __repr__(self): # pragma: no cover
        return "<MyObject>"

Excluding all private methods with one config option does not make sense IMO - it would lead to wrong assumptions if one looks on the coverage results.

like image 137
dahrens Avatar answered Oct 28 '25 04:10

dahrens