diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py index 74fcd45a603..7474a27207a 100755 --- a/Lib/test/test_array.py +++ b/Lib/test/test_array.py @@ -1,16 +1,26 @@ #! /usr/bin/env python """Test the arraymodule. -Roger E. Masse + Roger E. Masse """ import array +from test_support import verbose + +def main(): + + testtype('c', 'c') + + for type in (['b', 'h', 'i', 'l', 'f', 'd']): + testtype(type, 1) + def testtype(type, example): a = array.array(type) a.append(example) - #print 40*'*' - #print 'array after append: ', a + if verbose: + print 40*'*' + print 'array after append: ', a a.typecode a.itemsize if a.typecode in ('i', 'b', 'h', 'l'): @@ -19,22 +29,24 @@ def testtype(type, example): if a.typecode == 'c': f = open('/etc/passwd', 'r') a.fromfile(f, 10) - #print 'char array with 10 bytes of /etc/passwd appended: ', a + if verbose: + print 'char array with 10 bytes of /etc/passwd appended: ', a a.fromlist(['a', 'b', 'c']) - #print 'char array with list appended: ', a + if verbose: + print 'char array with list appended: ', a a.insert(0, example) - #print 'array of %s after inserting another:' % a.typecode, a + if verbose: + print 'array of %s after inserting another:' % a.typecode, a f = open('/dev/null', 'w') a.tofile(f) a.tolist() a.tostring() - #print 'array of %s converted to a list: ' % a.typecode, a.tolist() - #print 'array of %s converted to a string: ' % a.typecode, a.tostring() - -testtype('c', 'c') - -for type in (['b', 'h', 'i', 'l', 'f', 'd']): - testtype(type, 1) + if verbose: + print 'array of %s converted to a list: ' % a.typecode, a.tolist() + if verbose: + print 'array of %s converted to a string: ' \ + % a.typecode, a.tostring() +main() diff --git a/Lib/test/test_cmath.py b/Lib/test/test_cmath.py index 8c452d734d0..d7b1b886e13 100755 --- a/Lib/test/test_cmath.py +++ b/Lib/test/test_cmath.py @@ -3,20 +3,33 @@ Roger E. Masse """ import cmath +from test_support import verbose -cmath.acos(1.0) -cmath.acosh(1.0) -cmath.asin(1.0) -cmath.asinh(1.0) -cmath.atan(0.2) -cmath.atanh(0.3) -cmath.cos(1.0) -cmath.cosh(1.0) -cmath.exp(1.0) -cmath.log(1.0) -cmath.log10(1.0) -cmath.sin(1.0) -cmath.sinh(1.0) -cmath.sqrt(1.0) -cmath.tan(1.0) -cmath.tanh(1.0) +testdict = {'acos' : 1.0, + 'acosh' : 1.0, + 'asin' : 1.0, + 'asinh' : 1.0, + 'atan' : 0.2, + 'atanh' : 0.2, + 'cos' : 1.0, + 'cosh' : 1.0, + 'exp' : 1.0, + 'log' : 1.0, + 'log10' : 1.0, + 'sin' : 1.0, + 'sinh' : 1.0, + 'sqrt' : 1.0, + 'tan' : 1.0, + 'tanh' : 1.0} + +for func in testdict.keys(): + f = getattr(cmath, func) + r = f(testdict[func]) + if verbose: + print 'Calling %s(%f) = %f' % (func, testdict[func], abs(r)) + +p = cmath.pi +e = cmath.e +if verbose: + print 'PI = ', abs(p) + print 'E = ', abs(e) diff --git a/Lib/test/test_crypt.py b/Lib/test/test_crypt.py index 6fbb780c531..0685c95eb1e 100755 --- a/Lib/test/test_crypt.py +++ b/Lib/test/test_crypt.py @@ -2,11 +2,10 @@ """Simple test script for cryptmodule.c Roger E. Masse """ -verbose = 0 -if __name__ == '__main__': - verbose = 1 - + +from test_support import verbose import crypt + c = crypt.crypt('mypassword', 'ab') if verbose: print 'Test encryption: ', c diff --git a/Lib/test/test_dbm.py b/Lib/test/test_dbm.py index be24c66fe4e..45f5f3764bd 100755 --- a/Lib/test/test_dbm.py +++ b/Lib/test/test_dbm.py @@ -4,13 +4,18 @@ """ import dbm from dbm import error +from test_support import verbose + filename= '/tmp/delete_me' d = dbm.open(filename, 'c') d['a'] = 'b' d['12345678910'] = '019237410982340912840198242' d.keys() -d.has_key('a') +if d.has_key('a'): + if verbose: + print 'Test dbm keys: ', d.keys() + d.close() d = dbm.open(filename, 'r') d.close() diff --git a/Lib/test/test_dl.py b/Lib/test/test_dl.py index 37ff9c64023..e85bae92610 100755 --- a/Lib/test/test_dl.py +++ b/Lib/test/test_dl.py @@ -2,11 +2,9 @@ """Test dlmodule.c Roger E. Masse revised strategy by Barry Warsaw """ -verbose = 0 -if __name__ == '__main__': - verbose = 1 import dl +from test_support import verbose sharedlibs = [ # SunOS/Solaris diff --git a/Lib/test/test_errno.py b/Lib/test/test_errno.py index a7c77fadac2..6951255becd 100755 --- a/Lib/test/test_errno.py +++ b/Lib/test/test_errno.py @@ -2,12 +2,9 @@ """Test the errno module Roger E. Masse """ -verbose = 0 -if __name__ == '__main__': - verbose = 1 - import errno +from test_support import verbose errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', 'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF', @@ -37,7 +34,7 @@ errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', 'EUSERS', 'EWOULDBLOCK', 'EXDEV', 'EXFULL'] # -# This is is a wee bit bogus since the module pnly conditionally adds +# This is is a wee bit bogus since the module only conditionally adds # errno constants if they have been defined by errno.h However, this # test seems to work on SGI, Sparc & intel Solaris, and linux. # diff --git a/Lib/test/test_fcntl.py b/Lib/test/test_fcntl.py index 76391343f6a..4929fbb3fe1 100755 --- a/Lib/test/test_fcntl.py +++ b/Lib/test/test_fcntl.py @@ -6,10 +6,7 @@ import struct import fcntl import FCNTL import os - -verbose = 0 -if __name__ == '__main__': - verbose = 1 +from test_support import verbose filename = '/tmp/delete-me' diff --git a/Lib/test/test_gdbm.py b/Lib/test/test_gdbm.py index d0d705ae6eb..22db6aaa9ef 100755 --- a/Lib/test/test_gdbm.py +++ b/Lib/test/test_gdbm.py @@ -2,12 +2,11 @@ """Test script for the gdbm module Roger E. Masse """ -verbose = 0 -if __name__ == '__main__': - verbose = 1 import gdbm from gdbm import error +from test_support import verbose + filename= '/tmp/delete_me' g = gdbm.open(filename, 'c') diff --git a/Lib/test/test_grp.py b/Lib/test/test_grp.py index 122f2fd8f3e..458ed38d3cb 100755 --- a/Lib/test/test_grp.py +++ b/Lib/test/test_grp.py @@ -2,11 +2,9 @@ """Test script for the grp module Roger E. Masse """ -verbose = 0 -if __name__ == '__main__': - verbose = 1 - + import grp +from test_support import verbose groups = grp.getgrall() if verbose: