summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1996-12-20 22:36:52 (GMT)
committerRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1996-12-20 22:36:52 (GMT)
commitfab8ab80674375b945e93792701c672af98da067 (patch)
treec9cf051ed834a35c4805d3303bfe0ed3fa39d101 /Lib/test
parent4b722788ae2bbd5595aef38f4fd7221a3ab88372 (diff)
downloadcpython-fab8ab80674375b945e93792701c672af98da067.zip
cpython-fab8ab80674375b945e93792701c672af98da067.tar.gz
cpython-fab8ab80674375b945e93792701c672af98da067.tar.bz2
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.
Diffstat (limited to 'Lib/test')
-rwxr-xr-xLib/test/test_array.py38
-rwxr-xr-xLib/test/test_cmath.py45
-rwxr-xr-xLib/test/test_crypt.py7
-rwxr-xr-xLib/test/test_dbm.py7
-rwxr-xr-xLib/test/test_dl.py4
-rwxr-xr-xLib/test/test_errno.py7
-rwxr-xr-xLib/test/test_fcntl.py5
-rwxr-xr-xLib/test/test_gdbm.py5
-rwxr-xr-xLib/test/test_grp.py6
9 files changed, 71 insertions, 53 deletions
diff --git a/Lib/test/test_array.py b/Lib/test/test_array.py
index 74fcd45..7474a27 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 8c452d7..d7b1b88 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 6fbb780..0685c95 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 be24c66..45f5f37 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 37ff9c6..e85bae9 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 a7c77fa..6951255 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 7639134..4929fbb 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 d0d705a..22db6aa 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 122f2fd..458ed38 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: