Closed szabolcsdombi closed 7 years ago
Hmm, can you elaborate on what this fixes exactly?
Running python -m tbvaccine test_main.py
prints __name__ is builtins
and quits without an exception.
It is useful when running a single unittest. ( example )
test_main.py:
print('__name__ is %r' % __name__)
if __name__ == '__main__':
raise Exception('hello')
Ah, I see, thanks. Hopefully it doesn't break anything else by overwriting __name__
when it shouldn't.
Not sure if it will override the __name__
for further imports. those get a different globals()
and locals()
Tested import with a random module:
__name__ is 'K' # print from K.py
__name__ is '__main__' # print from test_main.py
Sounds good, thanks!
if
for main programs