uzla
uzla

Reputation: 525

Excluding line of code from pybuilder coverage

While PyBuilder Coverage is great excluding files, I could not find a property to set or any other way to exclude specific function or line of code.

For example I have a RESTFUL service that unittest tests, but i also have some functions outise of tested classes that I don't want to test explicitly. if that would be a standalone Coverage execution then it would be possible to change Coverage configuration file .coveragerc to something with below

[report]
exclude_lines = def MyUndesiredToBeTestedFunction

However, I could not find no obvious access to it from PyBuilder.

Any help of in finding Coverage configuration file .coveragerc that is used by PyBuilder run or other solution is welcomed!

Upvotes: 0

Views: 567

Answers (1)

Fabian
Fabian

Reputation: 529

for me it works if I place the .coveragerc file in the project root of my pybuilder project (pybuilder verion 0.11.10) with the following example content:

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
    # Have to re-enable the standard pragma
    pragma: no cover
    # custom
    def __[a-zA-Z]+\(

Tips:

  • assure your regex is correct
  • try with the .* regex (coverage should then be 100%)

Upvotes: 1

Related Questions