diff options
author | Guido van Rossum <guido@python.org> | 2000-09-01 19:25:51 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-09-01 19:25:51 (GMT) |
commit | 8d691c842289cf4453f282637765f07113a7cc17 (patch) | |
tree | 3a7819d53d7578cf728d3bcfecba7daebb6981db /Lib/dos-8x3/test_ope.py | |
parent | 29201d490511b2af863e07fdf5cb247fc9117c2f (diff) | |
download | cpython-8d691c842289cf4453f282637765f07113a7cc17.zip cpython-8d691c842289cf4453f282637765f07113a7cc17.tar.gz cpython-8d691c842289cf4453f282637765f07113a7cc17.tar.bz2 |
The usual
Diffstat (limited to 'Lib/dos-8x3/test_ope.py')
-rwxr-xr-x | Lib/dos-8x3/test_ope.py | 89 |
1 files changed, 17 insertions, 72 deletions
diff --git a/Lib/dos-8x3/test_ope.py b/Lib/dos-8x3/test_ope.py index 8d3864c..723e57c 100755 --- a/Lib/dos-8x3/test_ope.py +++ b/Lib/dos-8x3/test_ope.py @@ -1,77 +1,22 @@ -import operator -import sys +# Test to see if openpty works. (But don't worry if it isn't available.) -def test(name, input, output, *args): - print 'testing:', name - f = getattr(operator, name) - params = (input,) + args - try: - val = apply(f, params) - except: - val = sys.exc_type - if val <> output: - print '%s%s = %s: %s expected' % (f.__name__, params, `val`, `output`) +import os +from test_support import verbose, TestFailed, TestSkipped -test('abs', -1, 1) -test('add', 3, 7, 4) -test('and_', 0xf, 0xa, 0xa) -test('concat', 'py', 'python', 'thon') +try: + if verbose: + print "Calling os.openpty()" + master, slave = os.openpty() + if verbose: + print "(master, slave) = (%d, %d)"%(master, slave) +except AttributeError: + raise TestSkipped, "No openpty() available." -test('countOf', [1, 2, 1, 3, 1, 4], 1, 3) +if not os.isatty(master): + raise TestFailed, "Master-end of pty is not a terminal." +if not os.isatty(slave): + raise TestFailed, "Slave-end of pty is not a terminal." -a = [4, 3, 2, 1] -test('delitem', a, None, 1) -if a <> [4, 2, 1]: - print 'delitem() failed' +os.write(slave, 'Ping!') +print os.read(master, 1024) -a = range(10) -test('delslice', a, None, 2, 8) -if a <> [0, 1, 8, 9]: - print 'delslice() failed' - -a = range(10) -test('div', 5, 2, 2) -test('getitem', a, 2, 2) -test('getslice', a, [4, 5], 4, 6) -test('indexOf', [4, 3, 2, 1], 1, 3) -test('inv', 4, -5) -test('isCallable', 4, 0) -test('isCallable', operator.isCallable, 1) -test('isMappingType', operator.isMappingType, 0) -test('isMappingType', operator.__dict__, 1) -test('isNumberType', 8.3, 1) -test('isNumberType', dir(), 0) -test('isSequenceType', dir(), 1) -test('isSequenceType', 'yeahbuddy', 1) -test('isSequenceType', 3, 0) -test('lshift', 5, 10, 1) -test('mod', 5, 1, 2) -test('mul', 5, 10, 2) -test('neg', 5, -5) -test('or_', 0xa, 0xf, 0x5) -test('pos', -5, -5) - -a = range(3) -test('repeat', a, a+a, 2) -test('rshift', 5, 2, 1) - -test('sequenceIncludes', range(4), 1, 2) -test('sequenceIncludes', range(4), 0, 5) - -test('setitem', a, None, 0, 2) -if a <> [2, 1, 2]: - print 'setitem() failed' - -a = range(4) -test('setslice', a, None, 1, 3, [2, 1]) -if a <> [0, 2, 1, 3]: - print 'setslice() failed:', a - -test('sub', 5, 2, 3) -test('truth', 5, 1) -test('truth', [], 0) -test('xor', 0xb, 0x7, 0xc) - - -# some negative tests -test('indexOf', [4, 3, 2, 1], ValueError, 9) |