osdir.com


[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 Wed, 1 May 2019 at 13:53, Chris Withers <chris at withers.org> wrote:
>
> On 01/05/2019 13:37, Paul Moore wrote:
> > I agree - removing this just to make the coverage figures look pretty
> > seems like the wrong motivation.
> >
> > Configuring coverage to understand that you want to exclude these
> > lines from the checking would be fine, as would accepting that a
> > coverage of slightly less than 100% is OK. Removing functionality that
> > people use (whether or not they have other ways of getting the same
> > results) needs a stronger justification, IMO.
>
> It's an interesting point; I personally don't see much value in coverage
> of less than 100%, if you're going to look at coverage: no-one is going
> to focus on or potentially even notice whether coverage moved from 99%
> to 99% (no typo), even though a bunch of new uncovered code may have
> been introduced.

That's a fair point.

> If people are actually using these blocks, then so be it, but it feels
> like the people who want them to stick around are saying they're using
> them just on the off chance they might use them, which feels like a poor
> reason to keep a bunch of dead code around.

If your argument was "this is dead code, and should be removed to help
future maintenance", I'd have no problem with that. My point was
simply that I think that adjusting the code to make the coverage stats
hit 100% feels like going at things the wrong way round.

Is it really that difficult to simply tell coverage to ignore them? I
thought someone had already pointed to a coveragerc file that let you
do this.

Personally, I don't use those blocks at all, so it doesn't matter to
me whether they stay or go in any practical sense.
Paul