]> granicus.if.org Git - python/commitdiff
Add test_main() functions to various tests where it was simple to do. Done so
authorBrett Cannon <bcannon@gmail.com>
Mon, 3 Mar 2008 04:19:29 +0000 (04:19 +0000)
committerBrett Cannon <bcannon@gmail.com>
Mon, 3 Mar 2008 04:19:29 +0000 (04:19 +0000)
that regrtest can execute the test_main() directly instead of relying on import
side-effects.

Lib/test/test_al.py
Lib/test/test_audioop.py
Lib/test/test_cd.py
Lib/test/test_cl.py
Lib/test/test_dbm.py
Lib/test/test_gl.py
Lib/test/test_imageop.py
Lib/test/test_imgfile.py
Lib/test/test_sunaudiodev.py

index 02876f0b38c2a1d16d0d1460e6d82733ddb3842c..54496c12196630534ac33cbe19a112be0231db97 100755 (executable)
@@ -11,7 +11,7 @@ alattrs = ['__doc__', '__name__', 'getdefault', 'getminmax', 'getname', 'getpara
 # This is a very unobtrusive test for the existence of the al module and all its
 # attributes.  More comprehensive examples can be found in Demo/al
 
-def main():
+def test_main():
     # touch all the attributes of al without doing anything
     if verbose:
         print 'Touching al module attributes...'
@@ -20,4 +20,6 @@ def main():
             print 'touching: ', attr
         getattr(al, attr)
 
-main()
+
+if __name__ == '__main__':
+    test_main()
index f585733eacc9438ef6232e6873cd42ce4287feca..ce5287cfd8b2eb215d09abc079184b0877f03fad 100644 (file)
@@ -269,7 +269,7 @@ def testone(name, data):
     if not rv:
         print 'Test FAILED for audioop.'+name+'()'
 
-def testall():
+def test_main():
     data = [gendata1(), gendata2(), gendata4()]
     names = dir(audioop)
     # We know there is a routine 'add'
@@ -279,4 +279,8 @@ def testall():
             routines.append(n)
     for n in routines:
         testone(n, data)
-testall()
+
+
+
+if __name__ == '__main__':
+    test_main()
index d85621178a7a9bc490ddafde0a24311521b32581..daad223828290e79ef34c815e0195d7e645566de 100755 (executable)
@@ -14,7 +14,7 @@ cdattrs = ['BLOCKSIZE', 'CDROM', 'DATASIZE', 'ERROR', 'NODISC', 'PAUSED', 'PLAYI
 # attributes.  More comprehensive examples can be found in Demo/cd and
 # require that you have a CD and a CD ROM drive
 
-def main():
+def test_main():
     # touch all the attributes of cd without doing anything
     if verbose:
         print 'Touching cd module attributes...'
@@ -23,4 +23,7 @@ def main():
             print 'touching: ', attr
         getattr(cd, attr)
 
-main()
+
+
+if __name__ == '__main__':
+    test_main()
index abfe3c19f5785ed5845a083991dd4944649866b5..a2728b7df1d5e13eacff8996faa7f4205b06ba41 100755 (executable)
@@ -66,7 +66,7 @@ clattrs = ['ADDED_ALGORITHM_ERROR', 'ALAW', 'ALGORITHM_ID',
 # This is a very inobtrusive test for the existence of the cl
 # module and all its attributes.
 
-def main():
+def test_main():
     # touch all the attributes of al without doing anything
     if verbose:
         print 'Touching cl module attributes...'
@@ -75,4 +75,7 @@ def main():
             print 'touching: ', attr
         getattr(cl, attr)
 
-main()
+
+
+if __name__ == '__main__':
+    test_main()
index 4da0932bfc60e0eed6e6c9bda34a1395dce6c6b0..6b57efb0a85b84036d482c1bc37c3b926541c7f2 100755 (executable)
@@ -43,12 +43,18 @@ def test_modes():
     d = dbm.open(filename, 'n')
     d.close()
 
-cleanup()
-try:
-    test_keys()
-    test_modes()
-except:
+def test_main():
     cleanup()
-    raise
+    try:
+        test_keys()
+        test_modes()
+    except:
+        cleanup()
+        raise
 
-cleanup()
+    cleanup()
+
+
+
+if __name__ == '__main__':
+    test_main()
index c9cce7760769a466d32ef7c8604a6b0e31715062..20fd776fd18f2e9d5b8c7de81cb95e8aef953525 100755 (executable)
@@ -81,7 +81,7 @@ glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
 'xfpt4s', 'xfpti', 'xfpts', 'zbuffer', 'zclear', 'zdraw', 'zfunction',
 'zsource', 'zwritemask']
 
-def main():
+def test_main():
     # insure that we at least have an X display before continuing.
     import os
     try:
@@ -147,4 +147,6 @@ def main():
         print 'winclose'
     gl.winclose(w)
 
-main()
+
+if __name__ == '__main__':
+    test_main()
index 770c9f3c3fbb8b08ae32f70fcf784b048e196c8f..3b14357483c18783fd9fbad05986864a12d5bab2 100755 (executable)
@@ -11,7 +11,7 @@ import imageop, uu, os, imgfile
 
 import warnings
 
-def main():
+def test_main():
 
     # Create binary test files
     uu.decode(get_qualified_path('testrgb'+os.extsep+'uue'), 'test'+os.extsep+'rgb')
@@ -145,4 +145,5 @@ def get_qualified_path(name):
             return fullname
     return name
 
-main()
+if __name__ == '__main__':
+    test_main()
index 11311c4f437865b90cbe2ed163b8ed8f6880f1a6..ecc02ea67ae1a8090dcda6c0e9257760888471f2 100755 (executable)
@@ -9,20 +9,6 @@ from test.test_support import verbose, unlink, findfile
 import imgfile, uu
 
 
-def main():
-
-    uu.decode(findfile('testrgb.uue'), 'test.rgb')
-    uu.decode(findfile('greyrgb.uue'), 'greytest.rgb')
-
-    # Test a 3 byte color image
-    testimage('test.rgb')
-
-    # Test a 1 byte greyscale image
-    testimage('greytest.rgb')
-
-    unlink('test.rgb')
-    unlink('greytest.rgb')
-
 def testimage(name):
     """Run through the imgfile's battery of possible methods
        on the image passed in name.
@@ -113,4 +99,20 @@ def testimage(name):
 
     os.unlink(outputfile)
 
-main()
+
+def test_main():
+
+    uu.decode(findfile('testrgb.uue'), 'test.rgb')
+    uu.decode(findfile('greyrgb.uue'), 'greytest.rgb')
+
+    # Test a 3 byte color image
+    testimage('test.rgb')
+
+    # Test a 1 byte greyscale image
+    testimage('greytest.rgb')
+
+    unlink('test.rgb')
+    unlink('greytest.rgb')
+
+if __name__ == '__main__':
+    test_main()
index 375054207f5656b5a8eab1cec6936efda558e6c6..470fff82ec1838b111807c099d54d4618c7cb389 100644 (file)
@@ -22,7 +22,11 @@ def play_sound_file(path):
         a.write(data)
         a.close()
 
-def test():
+
+def test_main():
     play_sound_file(findfile('audiotest.au'))
 
-test()
+
+
+if __name__ == '__main__':
+    test_main()