to signify a test that should be marked as 'skipped' rather than 'failed'.
Also 'document' it, in README.
straightforward. When a test case is run, the output is compared with the
expected output that is stored in .../Lib/test/output. If the test runs to
completion and the actual and expected outputs match, the test succeeds, if
-not, it fails. If an ImportError is raised, the test is not run.
+not, it fails. If an ImportError or test_support.TestSkipped error is
+raised, the test is not run.
You will be writing unit tests (isolated tests of functions and objects
defined by the module) using white box techniques. Unlike black box
"""
import binhex
import tempfile
-from test_support import verbose
+from test_support import verbose, TestSkipped
def test():
fname2 = tempfile.mktemp()
f = open(fname1, 'w')
except:
- raise ImportError, "Cannot test binhex without a temp file"
+ raise TestSkipped, "Cannot test binhex without a temp file"
start = 'Jack is my hero'
f.write(start)
"""
import dl
-from test_support import verbose
+from test_support import verbose,TestSkipped
sharedlibs = [
('/usr/lib/libc.so', 'getpid'),
print 'worked!'
break
else:
- raise ImportError, 'Could not open any shared libraries'
+ raise TestSkipped, 'Could not open any shared libraries'
"""
import os, sys, time, thread
+from test_support import TestSkipped
try:
os.fork
except AttributeError:
- raise ImportError, "os.fork not defined -- skipping test_fork1"
+ raise TestSkipped, "os.fork not defined -- skipping test_fork1"
LONGSLEEP = 2
taken mostly from the documentation.
Roger E. Masse
"""
-from test_support import verbose
+from test_support import verbose, TestSkipped
import gl, GL, time
glattrs = ['RGBcolor', 'RGBcursor', 'RGBmode', 'RGBrange', 'RGBwritemask',
try:
display = os.environ['DISPLAY']
except:
- # Raise ImportError because regrtest.py handles it specially.
- raise ImportError, "No $DISPLAY -- skipping gl test"
+ raise TestSkipped, "No $DISPLAY -- skipping gl test"
# touch all the attributes of gl without doing anything
if verbose:
-from test_support import verbose, TestFailed
+from test_support import verbose, TestFailed, TestSkipped
import nis
print 'nis.maps()'
if verbose:
raise TestFailed, msg
# only do this if running under the regression suite
- raise ImportError, msg
+ raise TestSkipped, msg
done = 0
for nismap in maps:
# Test to see if openpty works. (But don't worry if it isn't available.)
import os
-from test_support import verbose, TestFailed
+from test_support import verbose, TestFailed, TestSkipped
try:
if verbose:
if verbose:
print "(master, slave) = (%d, %d)"%(master, slave)
except AttributeError:
- raise ImportError, "No openpty() available."
+ raise TestSkipped, "No openpty() available."
if not os.isatty(master):
raise TestFailed, "Master-end of pty is not a terminal."
import pty, os, sys, string
-from test_support import verbose, TestFailed
+from test_support import verbose, TestFailed, TestSkipped
TEST_STRING_1 = "I wish to buy a fish license."
TEST_STRING_2 = "For my pet fish, Eric."
debug("Got slave_fd '%d'"%slave_fd)
except OSError:
# " An optional feature could not be imported " ... ?
- raise ImportError, "Pseudo-terminals (seemingly) not functional."
+ raise TestSkipped, "Pseudo-terminals (seemingly) not functional."
if not os.isatty(master_fd):
raise TestFailed, "master_fd is not a tty"
# Test the signal module
-from test_support import verbose
+from test_support import verbose, TestSkipped
import signal
import os
import sys
if sys.platform[:3] in ('win', 'os2'):
- raise ImportError, "Can't test signal on %s" % sys.platform[:3]
+ raise TestSkipped, "Can't test signal on %s" % sys.platform[:3]
if verbose:
x = '-x'
-from test_support import verbose
+from test_support import verbose, TestSkipped
import string_tests
import string, sys
try:
''.join
except AttributeError:
- raise ImportError
+ raise TestSkipped
def test(name, input, output, *args):
if verbose: