Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot

of effort to do so.
This commit is contained in:
Brett Cannon 2008-04-01 12:46:02 +00:00
parent 8d2a90af2d
commit 8820f2a979
4 changed files with 36 additions and 18 deletions

View File

@ -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()

View File

@ -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()

View File

@ -38,3 +38,8 @@ class FrozenTests(unittest.TestCase):
def test_main():
run_unittest(FrozenTests)
if __name__ == '__main__':
test_main()

View File

@ -13,3 +13,7 @@ def suite():
def test_main():
run_unittest(suite())
if __name__ == '__main__':
test_main()