Many scripts, but small changes. Update the way the scripts obtain the

'verbose' flag ala GvR updated test harness architecture.

Old way:

	verbose = 0
	if __name__ == '__main__':
		verbose = 1

New way:

	from test_support import verbose

Some other small readablility and functionality updates.
This commit is contained in:
Roger E. Masse 1996-12-20 22:36:52 +00:00
parent 4b722788ae
commit fab8ab8067
9 changed files with 71 additions and 53 deletions

View file

@ -1,16 +1,26 @@
#! /usr/bin/env python #! /usr/bin/env python
"""Test the arraymodule. """Test the arraymodule.
Roger E. Masse Roger E. Masse
""" """
import array 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): def testtype(type, example):
a = array.array(type) a = array.array(type)
a.append(example) a.append(example)
#print 40*'*' if verbose:
#print 'array after append: ', a print 40*'*'
print 'array after append: ', a
a.typecode a.typecode
a.itemsize a.itemsize
if a.typecode in ('i', 'b', 'h', 'l'): if a.typecode in ('i', 'b', 'h', 'l'):
@ -19,22 +29,24 @@ def testtype(type, example):
if a.typecode == 'c': if a.typecode == 'c':
f = open('/etc/passwd', 'r') f = open('/etc/passwd', 'r')
a.fromfile(f, 10) 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']) 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) 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') f = open('/dev/null', 'w')
a.tofile(f) a.tofile(f)
a.tolist() a.tolist()
a.tostring() a.tostring()
#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() print 'array of %s converted to a list: ' % a.typecode, a.tolist()
if verbose:
testtype('c', 'c') print 'array of %s converted to a string: ' \
% a.typecode, a.tostring()
for type in (['b', 'h', 'i', 'l', 'f', 'd']):
testtype(type, 1)
main()

View file

@ -3,20 +3,33 @@
Roger E. Masse Roger E. Masse
""" """
import cmath import cmath
from test_support import verbose
cmath.acos(1.0) testdict = {'acos' : 1.0,
cmath.acosh(1.0) 'acosh' : 1.0,
cmath.asin(1.0) 'asin' : 1.0,
cmath.asinh(1.0) 'asinh' : 1.0,
cmath.atan(0.2) 'atan' : 0.2,
cmath.atanh(0.3) 'atanh' : 0.2,
cmath.cos(1.0) 'cos' : 1.0,
cmath.cosh(1.0) 'cosh' : 1.0,
cmath.exp(1.0) 'exp' : 1.0,
cmath.log(1.0) 'log' : 1.0,
cmath.log10(1.0) 'log10' : 1.0,
cmath.sin(1.0) 'sin' : 1.0,
cmath.sinh(1.0) 'sinh' : 1.0,
cmath.sqrt(1.0) 'sqrt' : 1.0,
cmath.tan(1.0) 'tan' : 1.0,
cmath.tanh(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)

View file

@ -2,11 +2,10 @@
"""Simple test script for cryptmodule.c """Simple test script for cryptmodule.c
Roger E. Masse Roger E. Masse
""" """
verbose = 0
if __name__ == '__main__': from test_support import verbose
verbose = 1
import crypt import crypt
c = crypt.crypt('mypassword', 'ab') c = crypt.crypt('mypassword', 'ab')
if verbose: if verbose:
print 'Test encryption: ', c print 'Test encryption: ', c

View file

@ -4,13 +4,18 @@
""" """
import dbm import dbm
from dbm import error from dbm import error
from test_support import verbose
filename= '/tmp/delete_me' filename= '/tmp/delete_me'
d = dbm.open(filename, 'c') d = dbm.open(filename, 'c')
d['a'] = 'b' d['a'] = 'b'
d['12345678910'] = '019237410982340912840198242' d['12345678910'] = '019237410982340912840198242'
d.keys() d.keys()
d.has_key('a') if d.has_key('a'):
if verbose:
print 'Test dbm keys: ', d.keys()
d.close() d.close()
d = dbm.open(filename, 'r') d = dbm.open(filename, 'r')
d.close() d.close()

View file

@ -2,11 +2,9 @@
"""Test dlmodule.c """Test dlmodule.c
Roger E. Masse revised strategy by Barry Warsaw Roger E. Masse revised strategy by Barry Warsaw
""" """
verbose = 0
if __name__ == '__main__':
verbose = 1
import dl import dl
from test_support import verbose
sharedlibs = [ sharedlibs = [
# SunOS/Solaris # SunOS/Solaris

View file

@ -2,12 +2,9 @@
"""Test the errno module """Test the errno module
Roger E. Masse Roger E. Masse
""" """
verbose = 0
if __name__ == '__main__':
verbose = 1
import errno import errno
from test_support import verbose
errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV', errors = ['E2BIG', 'EACCES', 'EADDRINUSE', 'EADDRNOTAVAIL', 'EADV',
'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF', 'EAFNOSUPPORT', 'EAGAIN', 'EALREADY', 'EBADE', 'EBADF',
@ -37,7 +34,7 @@
'EUSERS', 'EWOULDBLOCK', 'EXDEV', 'EXFULL'] '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 # errno constants if they have been defined by errno.h However, this
# test seems to work on SGI, Sparc & intel Solaris, and linux. # test seems to work on SGI, Sparc & intel Solaris, and linux.
# #

View file

@ -6,10 +6,7 @@
import fcntl import fcntl
import FCNTL import FCNTL
import os import os
from test_support import verbose
verbose = 0
if __name__ == '__main__':
verbose = 1
filename = '/tmp/delete-me' filename = '/tmp/delete-me'

View file

@ -2,12 +2,11 @@
"""Test script for the gdbm module """Test script for the gdbm module
Roger E. Masse Roger E. Masse
""" """
verbose = 0
if __name__ == '__main__':
verbose = 1
import gdbm import gdbm
from gdbm import error from gdbm import error
from test_support import verbose
filename= '/tmp/delete_me' filename= '/tmp/delete_me'
g = gdbm.open(filename, 'c') g = gdbm.open(filename, 'c')

View file

@ -2,11 +2,9 @@
"""Test script for the grp module """Test script for the grp module
Roger E. Masse Roger E. Masse
""" """
verbose = 0
if __name__ == '__main__':
verbose = 1
import grp import grp
from test_support import verbose
groups = grp.getgrall() groups = grp.getgrall()
if verbose: if verbose: