[Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
On 5/1/2019 2:13 AM, Chris Withers wrote:
> On 01/05/2019 06:12, Terry Reedy wrote:
>> 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:
I am fairly sure these are the original lines. I added more to my
personal copy to exclude some things specific to idlelib files. Idlelib
files also have the same statement as the mock files. It is very handy
> Which .coveragerc are you referring to?
The file in the directory that contains Ned's coverage package.
At least that is where it is for me.
> There isn't one in the cpython repo
Since /coverage is not in the Python repo either, I would not expect it
> and a current release of coverage.py doesn't appear to exclude
> these lines for me:
> (line 44 in mock/tests/testsentinel.py)
I consider this a problem in the circleci coverage setup, not in the
mock files. A faulty exclude-lines section leads to a faulty coverage
calculation. Ned made it user-editable for a reason.
Terry Jan Reedy