-1

I came across this code snippet from doit a while ago, and was wondering about the comment about ignoring coverage:

# lazy way to ignore coverage in this file
if True: # pragma: no cover
    def main():
        import sys

        from doit.doit_cmd import DoitMain

        sys.exit(DoitMain().run(sys.argv[1:]))

    if __name__ == '__main__':
        main()

What coverage is the writer referencing and what exactly happens here? code coverage related?

padawin
  • 4,230
  • 15
  • 19
CIsForCookies
  • 12,097
  • 11
  • 59
  • 124
  • In this topic: https://stackoverflow.com/questions/195008/what-is-code-coverage-and-how-do-you-measure-it you can find explanation of what it is. – Daweo May 20 '19 at 09:06

1 Answers1

3

From Wikipedia (https://en.wikipedia.org/wiki/Code_coverage):

In computer science, test coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs

So this instruction tells the coverage too to ignore this block when computing the project's coverage.

In this case, it's probably ignored as the entry point of the application is itself not covered with tests and the author does not want it to affect the overall project coverage.

padawin
  • 4,230
  • 15
  • 19