Raise 'TestSkipped' (from the test_support) module rather than 'ImportError'

to signify a test that should be marked as 'skipped' rather than 'failed'.
Also 'document' it, in README.
This commit is contained in:
Thomas Wouters 2000-08-04 13:34:43 +00:00
parent 040c17fe38
commit b9fa0a843e
10 changed files with 20 additions and 19 deletions

View File

@ -12,7 +12,8 @@ functionality. The mechanics of how the test system operates are fairly
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

View File

@ -6,7 +6,7 @@
"""
import binhex
import tempfile
from test_support import verbose
from test_support import verbose, TestSkipped
def test():
@ -15,7 +15,7 @@ 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)

View File

@ -4,7 +4,7 @@
"""
import dl
from test_support import verbose
from test_support import verbose,TestSkipped
sharedlibs = [
('/usr/lib/libc.so', 'getpid'),
@ -29,4 +29,4 @@ for s, func in sharedlibs:
print 'worked!'
break
else:
raise ImportError, 'Could not open any shared libraries'
raise TestSkipped, 'Could not open any shared libraries'

View File

@ -9,11 +9,12 @@ active threads survive in the child after a fork(); this is an error.
"""
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

View File

@ -3,7 +3,7 @@
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',
@ -87,8 +87,7 @@ def main():
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:

View File

@ -1,4 +1,4 @@
from test_support import verbose, TestFailed
from test_support import verbose, TestFailed, TestSkipped
import nis
print 'nis.maps()'
@ -9,7 +9,7 @@ except nis.error, msg:
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:

View File

@ -1,7 +1,7 @@
# 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:
@ -10,7 +10,7 @@ try:
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."

View File

@ -1,5 +1,5 @@
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."
@ -25,7 +25,7 @@ try:
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"

View File

@ -1,11 +1,11 @@
# 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'

View File

@ -1,4 +1,4 @@
from test_support import verbose
from test_support import verbose, TestSkipped
import string_tests
import string, sys
@ -6,7 +6,7 @@ import string, sys
try:
''.join
except AttributeError:
raise ImportError
raise TestSkipped
def test(name, input, output, *args):
if verbose: