Kaydet (Commit) fab8ab80 authored tarafından Roger E. Masse's avatar Roger E. Masse

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.
üst 4b722788
#! /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()
......@@ -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)
......@@ -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
......@@ -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()
......
......@@ -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
......
......@@ -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.
#
......
......@@ -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'
......
......@@ -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')
......
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment