[Python-checkins] r62091 - python/trunk/Lib/test/test_code.py python/trunk/Lib/test/test_dl.py python/trunk/Lib/test/test_frozen.py python/trunk/Lib/test/test_lib2to3.py

brett.cannon python-checkins at python.org
Tue Apr 1 14:46:14 CEST 2008


Author: brett.cannon
Date: Tue Apr  1 14:46:02 2008
New Revision: 62091

Modified:
   python/trunk/Lib/test/test_code.py
   python/trunk/Lib/test/test_dl.py
   python/trunk/Lib/test/test_frozen.py
   python/trunk/Lib/test/test_lib2to3.py
Log:
Add ``if __name__ == '__main__'`` to some test files where it didn't take a lot
of effort to do so.


Modified: python/trunk/Lib/test/test_code.py
==============================================================================
--- python/trunk/Lib/test/test_code.py	(original)
+++ python/trunk/Lib/test/test_code.py	Tue Apr  1 14:46:02 2008
@@ -100,3 +100,7 @@
     from test.test_support import run_doctest
     from test import test_code
     run_doctest(test_code, verbose)
+
+
+if __name__ == '__main__':
+    test_main()

Modified: python/trunk/Lib/test/test_dl.py
==============================================================================
--- python/trunk/Lib/test/test_dl.py	(original)
+++ python/trunk/Lib/test/test_dl.py	Tue Apr  1 14:46:02 2008
@@ -13,22 +13,27 @@
     ('/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()

Modified: python/trunk/Lib/test/test_frozen.py
==============================================================================
--- python/trunk/Lib/test/test_frozen.py	(original)
+++ python/trunk/Lib/test/test_frozen.py	Tue Apr  1 14:46:02 2008
@@ -38,3 +38,8 @@
 
 def test_main():
     run_unittest(FrozenTests)
+
+
+
+if __name__ == '__main__':
+    test_main()

Modified: python/trunk/Lib/test/test_lib2to3.py
==============================================================================
--- python/trunk/Lib/test/test_lib2to3.py	(original)
+++ python/trunk/Lib/test/test_lib2to3.py	Tue Apr  1 14:46:02 2008
@@ -13,3 +13,7 @@
 
 def test_main():
     run_unittest(suite())
+
+
+if __name__ == '__main__':
+    test_main()


More information about the Python-checkins mailing list