[Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
Serhiy Storchaka
storchaka at gmail.com
Wed May 1 02:46:57 EDT 2019
More information about the Python-Dev mailing list
Wed May 1 02:46:57 EDT 2019
- Previous message (by thread): [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
- Next message (by thread): [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
01.05.19 00:24, Chris Withers пише: > I have a crazy idea of getting unittest.mock up to 100% code coverage. > > I noticed at the bottom of all of the test files in testmock/, there's a: > > if __name__ == '__main__': > unittest.main() > > ...block. > > How would people feel about these going away? I don't *think* they're > needed now that we have unittest discover, but thought I'd ask. 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 test_create_autospec (__main__.TestCallable) ... ok test_create_autospec_instance (__main__.TestCallable) ... ok test_hierarchy (__main__.TestCallable) ... ok test_non_callable (__main__.TestCallable) ... ok test_patch_spec (__main__.TestCallable) ... ok test_patch_spec_callable_class (__main__.TestCallable) ... ok test_patch_spec_instance (__main__.TestCallable) ... ok test_patch_spec_set (__main__.TestCallable) ... ok test_patch_spec_set_instance (__main__.TestCallable) ... ok test_subclasses (__main__.TestCallable) ... ok ---------------------------------------------------------------------- Ran 11 tests in 0.040s OK
- Previous message (by thread): [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
- Next message (by thread): [Python-Dev] "if __name__ == '__main__'" at the bottom of python unittest files
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list