[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files

On 4/30/2019 5:24 PM, Chris Withers wrote:
> Hi All,
> I have a crazy idea of getting unittest.mock up to 100% code coverage.
> I noticed at the bottom of all of the test files in testmock/, there's a:
> if __name__ == '__main__':
>  ??? unittest.main()
> ...block.

Such blocks should be excluded from coverage by the default .coveragerc 
file.  Mine came with

exclude_lines =
     # Don't complain if non-runnable code isn't run:
     if 0:
     if __name__ == .__main__.:
     if DEBUG:

Terry Jan Reedy