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

Matěj Cepl mcepl at cepl.eu
Thu May 2 12:24:28 EDT 2019


On 2019-05-01, 06:46 GMT, Serhiy Storchaka wrote:
> These lines were added for purpose. They are needed for 
> running tests in separate file as a script.
>
> $ ./python Lib/unittest/test/testmock/testcallable.py -v
> test_attributes (__main__.TestCallable) ... ok

Isn't the standard way how to run one module just?

    $ ./python -mtest -v testmock.testcallable

Best,

Matěj
-- 
https://matej.ceplovi.cz/blog/, Jabber: mcepl at ceplovi.cz
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
 
As long as we are thinking of natural values we must say that the
sun looks down on nothing half so good as a household laughing
together over a meal, or two friends talking over a pint of beer,
or a man alone reading a book that interests him; and that all
economies, politics, laws, armies, and institutions, save insofar
as they prolong and multiply such scenes, are a mere ploughing
the sand and sowing the ocean, a meaningless vanity and vexation
of the spirit. Collective activities are, of course, necessary,
but this is the end to which they are necessary.
  -- C.S. Lewis, “Membership” in “The Weight of Glory”



More information about the Python-Dev mailing list