[Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
chris at withers.org
Wed May 1 14:13:51 EDT 2019
On 01/05/2019 17:09, Stephen J. Turnbull wrote:
> Executive summary:
> "There should be a tool" (sorry, I'm not volunteering any time soon)
> that could be added to $VCS diff (say, "git coverage-diff" or "git
> diff --coverage").
That sounds like a very hard problem to solve...
> > 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.
> At least one person says he uses it, although I don't know how that
> fits with Robert's statement that "it was never needed".
Right, but the more we discuss this, the stronger my feeling that these
should be removed everywhere, rather than just the few in
unittest.test.test_mock that I intend to remove.
...sets up a fundamentally hostile sys.path. As Karthikeyan highlighted,
in https://bugs.python.org/issue29512 this resulted in a year's mucking
around on a new tool that was added, and resulted in that tool getting a
slightly more clumsy name.
./python -m unittest some.package.test_whatever
...uses exactly the same runner, just without the unfortunate sys.path
I thought https://www.python.org/dev/peps/pep-0582/ had something about
no longer add '.' to sys.path, but looks like I was mistaken.
More information about the Python-Dev