From 8820f2a979806d4e8966a809052870f8f895b2f4 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 1 Apr 2008 12:46:02 +0000 Subject: [PATCH] Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot of effort to do so. --- Lib/test/test_code.py | 4 ++++ Lib/test/test_dl.py | 41 ++++++++++++++++++++++------------------ Lib/test/test_frozen.py | 5 +++++ Lib/test/test_lib2to3.py | 4 ++++ 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py index 4e686385698..b69223d190d 100644 --- a/Lib/test/test_code.py +++ b/Lib/test/test_code.py @@ -100,3 +100,7 @@ def test_main(verbose=None): from test.test_support import run_doctest from test import test_code run_doctest(test_code, verbose) + + +if __name__ == '__main__': + test_main() diff --git a/Lib/test/test_dl.py b/Lib/test/test_dl.py index b70a4cfee24..a2e4460d13e 100755 --- a/Lib/test/test_dl.py +++ b/Lib/test/test_dl.py @@ -13,22 +13,27 @@ sharedlibs = [ ('/usr/lib/libc.dylib', 'getpid'), ] -for s, func in sharedlibs: - try: - if verbose: - print 'trying to open:', s, - l = dl.open(s) - except dl.error, err: - if verbose: - print 'failed', repr(str(err)) - pass +def test_main(): + for s, func in sharedlibs: + try: + if verbose: + print 'trying to open:', s, + l = dl.open(s) + except dl.error, err: + if verbose: + print 'failed', repr(str(err)) + pass + else: + if verbose: + print 'succeeded...', + l.call(func) + l.close() + if verbose: + print 'worked!' + break else: - if verbose: - print 'succeeded...', - l.call(func) - l.close() - if verbose: - print 'worked!' - break -else: - raise TestSkipped, 'Could not open any shared libraries' + raise TestSkipped, 'Could not open any shared libraries' + + +if __name__ == '__main__': + test_main() diff --git a/Lib/test/test_frozen.py b/Lib/test/test_frozen.py index 621720ca788..e981fb3ddb7 100644 --- a/Lib/test/test_frozen.py +++ b/Lib/test/test_frozen.py @@ -38,3 +38,8 @@ class FrozenTests(unittest.TestCase): def test_main(): run_unittest(FrozenTests) + + + +if __name__ == '__main__': + test_main() diff --git a/Lib/test/test_lib2to3.py b/Lib/test/test_lib2to3.py index beda6959936..161b9ddd242 100644 --- a/Lib/test/test_lib2to3.py +++ b/Lib/test/test_lib2to3.py @@ -13,3 +13,7 @@ def suite(): def test_main(): run_unittest(suite()) + + +if __name__ == '__main__': + test_main()