diff options
author | Brett Cannon <bcannon@gmail.com> | 2008-03-03 04:19:29 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2008-03-03 04:19:29 (GMT) |
commit | 7dbd91811d87b75cb43441ed6e356232bcf60d28 (patch) | |
tree | 8a6d0ac4e7c4adb7e724a1274e24d83f5b8e7481 /Lib/test | |
parent | 963c80fd45d8c94d15ea4085ce200365018a1556 (diff) | |
download | cpython-7dbd91811d87b75cb43441ed6e356232bcf60d28.zip cpython-7dbd91811d87b75cb43441ed6e356232bcf60d28.tar.gz cpython-7dbd91811d87b75cb43441ed6e356232bcf60d28.tar.bz2 |
Add test_main() functions to various tests where it was simple to do. Done so
that regrtest can execute the test_main() directly instead of relying on import
side-effects.
Diffstat (limited to 'Lib/test')
-rwxr-xr-x | Lib/test/test_al.py | 6 | ||||
-rw-r--r-- | Lib/test/test_audioop.py | 8 | ||||
-rwxr-xr-x | Lib/test/test_cd.py | 7 | ||||
-rwxr-xr-x | Lib/test/test_cl.py | 7 | ||||
-rwxr-xr-x | Lib/test/test_dbm.py | 20 | ||||
-rwxr-xr-x | Lib/test/test_gl.py | 6 | ||||
-rwxr-xr-x | Lib/test/test_imageop.py | 5 | ||||
-rwxr-xr-x | Lib/test/test_imgfile.py | 32 | ||||
-rw-r--r-- | Lib/test/test_sunaudiodev.py | 8 |
9 files changed, 63 insertions, 36 deletions
diff --git a/Lib/test/test_al.py b/Lib/test/test_al.py index 02876f0..54496c1 100755 --- a/Lib/test/test_al.py +++ b/Lib/test/test_al.py @@ -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() diff --git a/Lib/test/test_audioop.py b/Lib/test/test_audioop.py index f585733..ce5287c 100644 --- a/Lib/test/test_audioop.py +++ b/Lib/test/test_audioop.py @@ -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() diff --git a/Lib/test/test_cd.py b/Lib/test/test_cd.py index d856211..daad223 100755 --- a/Lib/test/test_cd.py +++ b/Lib/test/test_cd.py @@ -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() diff --git a/Lib/test/test_cl.py b/Lib/test/test_cl.py index abfe3c1..a2728b7 100755 --- a/Lib/test/test_cl.py +++ b/Lib/test/test_cl.py @@ -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() diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index 4da0932..6b57efb 100755 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -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() diff --git a/Lib/test/test_gl.py b/Lib/test/test_gl.py index c9cce77..20fd776 100755 --- a/Lib/test/test_gl.py +++ b/Lib/test/test_gl.py @@ -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() diff --git a/Lib/test/test_imageop.py b/Lib/test/test_imageop.py index 770c9f3..3b14357 100755 --- a/Lib/test/test_imageop.py +++ b/Lib/test/test_imageop.py @@ -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() diff --git a/Lib/test/test_imgfile.py b/Lib/test/test_imgfile.py index 11311c4..ecc02ea 100755 --- a/Lib/test/test_imgfile.py +++ b/Lib/test/test_imgfile.py @@ -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() diff --git a/Lib/test/test_sunaudiodev.py b/Lib/test/test_sunaudiodev.py index 3750542..470fff8 100644 --- a/Lib/test/test_sunaudiodev.py +++ b/Lib/test/test_sunaudiodev.py @@ -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() |